你知道嗎? IE 的 innerHTML 不能插入 script code ?
http://www.jsmadeeasy.com/javascripts/Advanced/innerHtml/innerHtml.htm
When using innerHTML to insert script, you must include the DEFER attribute in the script element.
http://big5.chinaz.com:88/blog.chinaz.com/u1/wilson/archives/2006/37879.shtml
不能插入 <script></script> 就算了, 竟然連 <a href=# onclick='my_script()'> 這種都不行.
在 FF 只要
var ie = (document.all)? true: false;
var obj = document.getElementById("recent");
obj.innerHTML="";
if (!ie) {
for (i=keep_recent.length -1; i >=0 ; i-- ) {
text ="<a href='javascript:gototo(\""+ keep_recent[i] + "\")>" + keep_recent[i] +"</a> ";
obj.innerHTML+=text;
if ( i%3 == 0) {
obj.innerHTML+="<br>";
}
}
return;
}
但是 IE 只能用 innerHTML塞入正常的 span tag, 然後再賦予其 onClick 等 function..
if (ie) {
/*
// 想先產生另一個 object 再複製過去也不行
var bugIE = document.createElement('span');
obj.appendChild(bugIE);
bugIE.innerHTML="<a href='javascript:gototo(\""+ keep_recent[i] + "\")>" + keep_recent[i] +"</a> ";
// alert(bugIE.innerHTML);
not work. http://www.jsmadeeasy.com/javascripts/Advanced/innerHtml/innerHtml.htm
.
*/
// Changes the cursor to an hourglass
function cursor_hand() {
document.body.style.cursor = 'hand';
}
// Returns the cursor to the default pointer
function cursor_clear() {
document.body.style.cursor = 'default';
}
var bugIE;
for (i=keep_recent.length -1; i >=0 ; i-- ) {
text ="<span id=span"+i+" style='text-decoration: underline;color: blue'>" + keep_recent[i] +"</span> ";
obj.innerHTML+=text;
if ( i%3 == 0) {
obj.innerHTML+="<br>";
} }}
}
for(i=0; i< keep_recent.length; i++ ){
var bugIE = document.getElementById('span'+i);
bugIE.onclick=function () {
gototo(this.innerHTML); };
bugIE.onmouseover=cursor_hand;
bugIE.onmouseout=cursor_clear;
}
}


more