技术交流,DH讲解. 之前照着天书夜读,用Delphi来弄了下循环体,现在就来弄一下条件判断吧.
首先肯定是我们经常看见的IF语句咯. Var
I: Integer;
Begin
I:= 99;
If (I> 0)And (I< 0) Then
Writeln('I>0')
Else
If (I> 10)And (I< 100) Then
Writeln('I>10 and I100');
End.
反汇编出来会是什么样子的呢?
Project5.dpr.12: I:= 99;
004AC44C B863000000 mov eax,$00000063
Project5.dpr.13: If (I> 0)And (I< 0) Then
004AC451 85C0 test eax,eax
004AC453 7E1F jle $004ac474
004AC455 85C0 test eax,eax
004AC457 7D1B jnl $004ac474
Project5.dpr.14: Writeln('I>0')
004AC459 A1DC314B00 mov eax,[$004b31dc]
004AC45E BAC4C44A00 mov edx,$004ac4c4
004AC463 E874BAF5FF call @Write0UString
004AC468 E8BF89F5FF call @WriteLn
004AC46D E83E7FF5FF call @_IOTest
004AC472 EB3E jmp $004ac4b2
Project5.dpr.16: If (I> 10)And (I< 100) Then
004AC474 83F80A cmp eax,$0a
004AC477 7E20 jle ......
String.prototype.Trim=function(){
returnthis.replace(/(^\s*)|(\s*$)/g,"");
}
String.prototype.LTrim=function(){
returnthis.replace(/(^\s*)/g,"");
}
String.prototype.RTrim=function(){
returnthis.replace(/(\s*$)/g,"");
} ......
function checkImgAddr(url){
var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("post",url,false);
xmlhttp.send();
if(xmlhttp.readyState==4){
if(xmlhttp.status==404){
return "File Not Exist.";
}else if(xmlhttp.status == 200){
return "File is Exist.";
}else{
return xmlhttp.status;
}
}
} ......
//获取页面数据
function getPageSize(){
var xScroll, yScroll;
if (window.innerHeight && window.scrollMaxY) {
xScroll = document.body.scrollWidth;
yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
xScroll = document.body.scrollWidth;
yScroll = document.body.scrollHeight;
} else{ // Explorer Macwould also work in Explorer 6 Strict, Mozilla and Safari
xScroll = document.body.offsetWidth;
yScroll = document.body.offsetHeight;
}
var windowWidth, windowHeight;
if (self.innerHeight) { // all except Explorer
windowWidth = self.innerWidth;
&nb ......
function QueryString(fieldName){
var urlString = location.search;
if (urlString != null) {
var typeQu = fieldName + "=";
var urlEnd = urlString.indexOf(typeQu);
if (urlEnd != -1) {
var paramsUrl = urlString.substring(urlEnd + typeQu.length);
var isEnd = paramsUrl.indexOf('&');
if (isEnd != -1) {
return paramsUrl.substring(0, isEnd);
}
else {
return paramsUrl;
}
}
return null;
}
} ......
JavaScript方法和技巧大全
1:基础知识
1 创建脚本块
1: <script language=”JavaScript”>
2: JavaScript code goes here
3: </script>
2 隐藏脚本代码
1: <script language=”JavaScript”>
2: <!--
3: document.write(“Hello”);
4: // -->
5: </script>
在不支持JavaScript的浏览器中将不执行相关代码
3 浏览器不支持的时候显示
1: <noscript>
2: Hello to the non-JavaScript browser.
3: </noscript>
4 链接外部脚本文件
1: <script language=”JavaScript” src="/”filename.js"”></script>
5 注释脚本
1: // This is a comment
2: document.write(“Hello”); // This is a comment
3: /*
4: All of this
5: is a comment
6: */
6 输出到浏览器
1: document.write(“<strong>Hello</strong>”);
7 定义变量
1: var myVariable = “some value”;
8 字符串相加
1: var myString = “String1& ......