方法一
<!DOCTYPE HTML PUBLIC "
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script type="text/javascript">
window
var tags = document
count = tags
time = new Date();
for(var i =
id = tags[i]
if(id){
if(ret[id]){
alert(id + "/n用時
return;
}else{
ret[id] = true;
}
}
}
alert("未找到相同ID");
}
</script>
</HEAD>
<BODY>
<script type="text/javascript">
(function(){
var html = []
for(var i =
html
};
//在隨機位置插入一個隨機的id
i = parseInt(Math
html[i] = html[i] + ("<div id=
document
})();
</script>
</BODY>
</HTML>
方法二
<!DOCTYPE HTML PUBLIC "
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script type="text/javascript">
function createDiv(){
var html = []
for(var i =
id = "divId" + parseInt(Math
html
}
document
}
window
createDiv();
var oID = {}
tags = document
for(var i =
id = tags[i]
if(id){
oID[id] = oID[id] ? oID[id] +
if(oID[id] >
result[id] = id + " " + oID[id]; } } } for(var o in result){
arr
}
alert(arr
};
</script>
</HEAD>
<BODY>
</BODY>
</HTML>
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20641.html