MozTW 討論區
https://forum.moztw.org/

使用javascript的insertBefore的method問題
https://forum.moztw.org/viewtopic.php?f=13&t=23891
1 頁 (共 1 頁)

發表人:  訪客 [ 2008-08-13, 18:29 ]
文章主題 :  使用javascript的insertBefore的method問題

我是看MSDN的body中的method:insertBefor
操作網址
http://samples.msdn.microsoft.com/works ... Before.htm

看他寫的這個method的標準是
This method is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1

但是在firefox3操作會有問題!(中文版、英文板皆試過)
可否請您確認一下
如方便可否請您回覆給我~
wilson.chen@104.com.tw

發表人:  shyangs [ 2008-08-13, 21:37 ]
文章主題 : 

代碼:
function insertElement()
    {
        var nod=document.createElement("li");
        oUL1.insertBefore(nod, oLIYellow);
        nod.innerText="Orange";
    }

應該改成
代碼:
function insertElement()
    {
        var nod=document.createElement("li");
        var oUL1=document.getElementById("oUL1");
        var oLIYellow=document.getElementById("oLIYellow");
        var newtext=document.createTextNode("Orange");
        nod.appendChild(newtext);
        oUL1.insertBefore(nod, oLIYellow);
    }


ps. 我只是一般會員

發表人:  kourge [ 2008-08-23, 17:16 ]
文章主題 : 

MSDN 的提供的文件常常會提供一些不合標準的示範,建議你用用 MDC 的文件:
http://developer.mozilla.org/en/DOM/ele ... sertBefore
反正都是英文。

1 頁 (共 1 頁) 所有顯示的時間為 UTC + 8 小時
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/