Javascript 如何在数组中使用doc.location.href.search

Javascript 如何在数组中使用doc.location.href.search,javascript,Javascript,我正在创建一个基本的Firefox插件,我想用它来阻止某些域名,并让它们重定向到另一个外部网页 如何让'doc.location.href.search'在VAR'blockedSites'中搜索? (如果有人知道如何解决Firefox加载正确重定向网站的问题,但在全屏模式下删除所有选项卡,也将受到欢迎) 这是迄今为止的代码: onPageLoad: function (aEvent) { var doc = aEvent.originalTarget; var bloc

我正在创建一个基本的Firefox插件,我想用它来阻止某些域名,并让它们重定向到另一个外部网页

如何让'doc.location.href.search'在VAR'blockedSites'中搜索? (如果有人知道如何解决Firefox加载正确重定向网站的问题,但在全屏模式下删除所有选项卡,也将受到欢迎)

这是迄今为止的代码:

    onPageLoad: function (aEvent) {
    var doc = aEvent.originalTarget;
    var blockedSites=["domain1.com","domain2.net","domain3.org"];
    if (doc.location.href.search("blockedSites") > -1)
{
    window.location = "http://redirect-to-this.com"
}
使用而不是
搜索

if (blockedSites.indexOf(doc.location.href) >= 0)
indexOf
将返回字符串在数组中的位置,因此它必须为0或更大才能成为被阻止的站点