簡體   English   中英

頁面加載后加載和執行腳本?

[英]Loading and executing scripts after page load?

I am trying to load an external javascript (jquery) via my Firefox addon to a third-party webpage, WebDeveloper addons shows the jquery script syntax getting successfully appended to the head section in "View Generated Source" but the script is not getting executed/ fetched?,我在我的插件中使用以下代碼來加載腳本:

function loadjscssfile(filename, filetype){
if (filetype=="js"){ //if filename is a external JavaScript file
  var fileref=document.createElement('script')
  fileref.setAttribute("type","text/javascript")
  fileref.setAttribute("src", filename)
  fileref.setAttribute('onload', 'firefoxInit()');

}
else if (filetype=="css"){ //if filename is an external CSS file
  var fileref=document.createElement("link")
  fileref.setAttribute("rel", "stylesheet")
  fileref.setAttribute("type", "text/css")
  fileref.setAttribute("href", filename)
}
if (typeof fileref!="undefined")
  document.getElementsByTagName("head")[0].appendChild(fileref)
}

請。 指導如何前進。

您可以在 javascript firefoxInit();末尾添加並刪除onload屬性分配。

暫無
暫無

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

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