由于即使在查看css或js文件时,也会触发扩展程序的页面加载,因此,我想添加另一条仅在当前页面的content-type为text / html时才触发扩展程序的检查。

//eg: at my page load handler
function onPageload(){

  // only want to proceed if content-type reflects a text/html or */html page
  if ( contentTypeIsHtml() ){
    //continue here
  }
}


contentTypeIsHtml()应该做什么?

最佳答案

您可以使用document.contentType属性获取内容类型(这不是标准的DOM,但扩展程序会使用它)

关于javascript - firefox扩展如何检测加载的页面的内容类型?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2847769/

10-12 12:35
查看更多