簡體   English   中英

document.getElementsByName()不是Firefox中的函數

[英]document.getElementsByName() is not a function in firefox

我的js代碼在Chrome和IE中工作正常,但是在Firefox中,控制台顯示:

TypeError:xmlDoc.getElementsByName不是一個函數

var nextSectionName = actSection.getElementsByTagName("clickArea")[actClickArea].getAttribute('linkTo');
actSection = xmlDoc.getElementsByName(nextSectionName)[0];

xmlDoc只是一個XML文件, actSection = xmlDoc.getElementsByTagName("section")[0]; 作品也很好。

您從window.document知道的某些屬性僅存在於HTML文檔中 ,通常不存在於XML文檔中。 這些屬性包括.referrer.head.body.images.images ,以及.write() .execCommand().getElementsByName()

在XML文檔中,只應使用id和class, name屬性是沒有意義的。 如果絕對必須匹配名稱,請使用屬性選擇器。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM