Javascript 重定向到具有Firefox扩展的区域设置页面
我希望有一个页面使用Javascript重定向到另一个页面。我试过使用document.location.href,但它不适用于本地页面(存储在硬盘中)。 有人知道什么东西能起作用吗 谢谢Javascript 重定向到具有Firefox扩展的区域设置页面,javascript,hyperlink,Javascript,Hyperlink,我希望有一个页面使用Javascript重定向到另一个页面。我试过使用document.location.href,但它不适用于本地页面(存储在硬盘中)。 有人知道什么东西能起作用吗 谢谢 布鲁诺是不是?我尝试了以下方法,效果很好: <html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8"> </head>
布鲁诺是不是?我尝试了以下方法,效果很好:
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
</head>
<body>
<input type="text" value="" id="test"/>
</body>
<script type="text/javascript">
document.location.href = "file:///C:/dev/PICCS/vb/binaries/";
</script>
</html>
document.location.href=”file:///C:/dev/PICCS/vb/binaries/";
在IE8和Chrome中测试,在扩展名的xul文件中发布:
function Read(file)
{
var ioService=Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var scriptableStream=Components
.classes["@mozilla.org/scriptableinputstream;1"]
.getService(Components.interfaces.nsIScriptableInputStream);
var channel=ioService.newChannel(file,null,null);
var input=channel.open();
scriptableStream.init(input);
var str=scriptableStream.read(input.available());
scriptableStream.close();
input.close();
return str;
}
gBrowser.addEventListener("DOMContentLoaded", function(e) {
var documentElement = e.originalTarget.defaultView.document;
var div = documentElement.createElement("div");
div.innerHTML = Read("chrome://firefox_extension/content/locale.html");
documentElement.body.appendChild(div);
},
false
);
完整的扩展名:请尝试
窗口。位置
document.location
是只读的。我已经尝试过了,但它不起作用。请看这个:这是IE的底线-由于安全原因不可能。我想这是一种安全措施。我已经尝试过你的技巧:文件确实打开了,但里面什么都没有Google Chrome,我的文件在wamp的www文件夹中。@Darin Dimitrov-是的,虽然我能访问的唯一版本是3.0.5