Base HREF and Javascript Location.href with IE vs NN
Just having a play with some JavaScript to generate a URL to redirect the user to.It appears that IE does take into consideration your < base xhref="" mce_href="" > in your header when executing a location.href=”" mce_href=”" command with IE. It does however work with NN. In my scenario it was due to a having images and CSS work relative to a different folder, with operations occuring in a different folder. This was due to my templating setup.
Instead of simply calling:
location.href=”myotherfolder/?do=whichever”;
you can build the whole URL using
location.href = window.location.protocol + “//” + window.location.host + window.location.pathname + “myotherfolder/?do=whichever”;
which sidesteps your base href declaration in your head HTML. May be useful to keep in mind.






It is important that you allow use the window.location to build your URL as you may inadvertantly move a person from a different protocol (eg, from HTTPS to HTTP). You also want to leave it built from the URL as you will not have to worry about moving the contents of your site to a different domain or folder on your hosting space.
Comment by Cameron Manderson — April 5, 2006 @ 5:59 pm