我正在尝试构建一个书签小程序,将当前的网址作为参数传递给另一个网址。
然而我发现这个
javascript:(function(){window.open("http://www.somesi.te/some/thing?url="+encodeURIComponent(window.location.href))})()
不起作用,而这个
javascript:(function(){window.location.href = "http://www.somesi.te/some/thing?url="+encodeURIComponent(window.location.href)})()
除了window.open
打开一个新窗口,window.location.href
改变位置的明显区别外,为什么后者有效,而前者只是打开另一个窗口到原始位置?
这是在Firefox上的情况。有趣的是,在Chrome上一切正常。
这是一种安全问题吗?
javascript:
链接几乎总是有害的。请代表您的用户,不要使用它们! - lonesomedayjavascript:(function(){var w = window.open(""); w.location.href = "http://www.somesi.te/some/thing?url="+encodeURIComponent(window.location.href)})()
是有效的。不是弹出窗口阻止的问题。 - simone