1 字符比较
很多时候字符返回会有点不一样,通过alert方式看,有时候看不出,也曾经让阿权纳闷了很久。
也可以通过比较他们的编码后的字符
另外,可以通过trim一下,去掉某些特殊字符:
2 json方式定义对象和数组挺简洁明快
注意定义对象里的变量是逗号分隔的
3 弹窗可以用链接的点击事件试试
4 数组随机
原创内容如转载请注明:来自 阿权的书房
很多时候字符返回会有点不一样,通过alert方式看,有时候看不出,也曾经让阿权纳闷了很久。
也可以通过比较他们的编码后的字符
alert(encodeURIComponent(a)+" - "+encodeURIComponent(b));
另外,可以通过trim一下,去掉某些特殊字符:
String.prototype.Trim = function() { return this.replace(/(^\s*)|(\s*$)/g, ""); }
String.prototype.LTrim = function() { return this.replace(/(^\s*)/g, ""); }
String.prototype.RTrim = function() { return this.replace(/(\s*$)/g, ""); }
String.prototype.LTrim = function() { return this.replace(/(^\s*)/g, ""); }
String.prototype.RTrim = function() { return this.replace(/(\s*$)/g, ""); }
2 json方式定义对象和数组挺简洁明快
myobj = {
a:'test',
b:[],
c:{},
f:function(a){
}
}
myarray = [];
a:'test',
b:[],
c:{},
f:function(a){
}
}
myarray = [];
注意定义对象里的变量是逗号分隔的
3 弹窗可以用链接的点击事件试试
<script language="javascript">
<!--
try{
var myurl = 'http://www.aslibra.com';
document.write('<a id="link" href="'+myurl+'" target="_target"></a>');
document.getElementById("link").click();
}catch(e){
window.open(myurl);
//location.replace(myurl);
}
//--></script>
<!--
try{
var myurl = 'http://www.aslibra.com';
document.write('<a id="link" href="'+myurl+'" target="_target"></a>');
document.getElementById("link").click();
}catch(e){
window.open(myurl);
//location.replace(myurl);
}
//--></script>
4 数组随机
var status_str = [
" www.aslibra.com ",
" www.baidu.com "];
function randomsort(a, b) {
return Math.random()>.5 ? -1 : 1;
}
status_str.sort(randomsort);
" www.aslibra.com ",
" www.baidu.com "];
function randomsort(a, b) {
return Math.random()>.5 ? -1 : 1;
}
status_str.sort(randomsort);
原创内容如转载请注明:来自 阿权的书房
收藏本文到网摘
佛与蜘蛛的问答
linux下硬盘复制
