0

I'd like to have a page redirecting to another using Javascript. I've tried with document.location.href but it doesn't work with local pages (stored in my hard drive). Does someone know something that would do the trick ?

thanks,

Bruno

Bruno
  • 8,497
  • 13
  • 38
  • 55

2 Answers2

0

Doesn't it? I've tried the following and it works fine:

<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>

Tested in IE8 and Chrome

James Wiseman
  • 29,946
  • 17
  • 95
  • 158
0

Posting this on the xul file of the extension :

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

);

the complete extension : http://uploadingit.com/file/xef7llflgmjgfzin/my_firefox_extension.xpi

Bruno
  • 8,497
  • 13
  • 38
  • 55