JavaScript的with语句
with语句
用于设置代码特定对象的作用域。
例:
var sMessage = "hello world";
with(sMessage)
{
alert(toUpperCase()); //输出 "HELLO WORLD"
}
with语句是运行缓慢的代码段,尤其是在已设置了属性值时。大多数情况下,尽量避免使用它。
相关文档:
with(document)
{
write ("test");
write
("dsasfda");
}
上面是用了with
如果不用的话就要这样写了
document.write (" ......
1.asp.net呼叫js
view
plain
copy
to clipboard
print
?
Response.Write("<mce:script language=javascript><!--
");
Response.Write("alert('欢迎您 ');"
);
Response.Write("location.href='login.aspx';"
)& ......
//String.prototype使用
//批量替换,比如:str.ReplaceAll([/a/g,/b/g,/c/g],["aaa","bbb","ccc"])
String.prototype.ReplaceAll=function (A,B) {
var C=this;
for(var i ......
JavaScript以ECMAScript标准作为功能基准,ECMAScript有5种原型类型:Undefined,Null,Boolean,Number和String。
可以用typeof来判断类型,例:
var sTemp = "test string";
alert(typeof sTem ......
ECMAScript中,switch语句可以用于字符串,而且能用不是常量的值说明情况:
var BLUE="blue" , RED = "red" , GREEN = "green";
switch(sColor)
{
case BLUE: alert("Blue"); break;
&nb ......