views:

264

answers:

4

I have a page that grabs values from the query string using javascript window.location. This works fine when run from a webserver but if I run it locally using IE6 by putting this in the address bar

c:\mysite\index.htm

Any query strings the site creates get lost and window.location just contains the location upto .htm.

I realize the example above has no query string but that page links off to pages that do. This also fails when running from a network share e.g \\server\mysite\index.htm. It seems to work fine in IE7+ and only fails in IE6.

Any ideas it's driving me crazy.

Edit : I've jsut realised this is happening on a modal window does that make any difference?

A: 

This could be a security issue in IE6. The only thing I can think of is using a HTA instead of a HTML file. Is that an option?

Charlie boy
A: 

Are you aware that window.location is not a simple string, but a structured object with fields? The querystring is in window.location.search - apparently IE6 simply does not include that part when printing the parent object.

Michael Borgwardt
yes I'm aware of this, IE6 seems to loose the search text when run offline
Gavin Draper
hm, that's a nasty quirk then.
Michael Borgwardt
it also seems to prepend the location with file:// not sure if this makes any difference in the way it runs
Gavin Draper
It prepends the location with file:// because you are using the file protocol rather than the HTTP protocol. As bobince points out, a querystring has no meaning in relation to the file protocol. It's an HTTP thing, so IE is perfectly within its rights to throw it away for file system access. If you want to use HTTP, you need to run an HTTP server.
NickFitz
+3  A: 

Query strings explicitly do not exist for URIs of the scheme ‘file’. See RFC1738. It makes no sense to put a ?query on the end of a ‘file:’ URI.

If you want to include extra location information available to scripts on the page, use a #fragment identifier and location.hash.

bobince
A: 

It seems that IE6 disregards any querystrings when running locally on modal windows. Got around the problem by passing the variables into the modal window as dialog arguments rather than querystrings.

Gavin Draper