Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Question: How do I stop IE from stripping off parameters from file URI pasted into address bar?

Description of a problem: I have a "simpleTest.html" page with only this JS code inside, that returns the current location of the browser:

console.log("document.URL: " + document.URL);
console.log("document.location: " + document.location)
console.log("document.location.href: " + document.location.href)
console.log("window.location: " + window.location)
console.log("parent.frames.document.location: " + parent.frames.document.location)

When I paste the address to this file in IE's address bar with some parameters, for instance:

file:///pathToFile/simpleTest.html?dupa=2

The link gets changed to:

file:///pathToFile/simpleTest.html

When I paste it for the 2nd time the parameters will stay there. If however in the meantime I access some other resources, I will have to paste it 2 more consecutive times for the parameters to remain.

Moreover, after I've place the website in my local Apache and access it through HTTP, the parameters remained:

http://127.0.0.1/pathToFile/simpleTest.html?dupa=2

It works fine for FF and Chrome, for both file and http protocols. Any ideas about this strange behavior in IE?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

file:/// will open a file on your drive or network drive using the OS. When using http:// you're telling the browser that this is a hypertext link to a file located on the Internet, not locally.

You're likely seeing the parameters after several tries because IE is just saving your history.

Also, having a ? in the URL implies you have some server-side scripting involved to process the URL parameter(s), which would not run unless through a web server.

share|improve this answer
    
Any idea how I could force IE to use browser engine instead of OS with a file protocol? –  user1581900 Jun 7 '13 at 13:26
    
I'm afraid that's handled at the system-level (like calling 'system' in a program), so outside a user's control :-/ I coded a product with an HTTP server built in and had a similar problem...the only solution was to send the file via HTTP, which albeit is slower. –  dan Jun 7 '13 at 14:02
    
One alternative is to use anchors with # instead of ?. That way it won't be removed, and you can still access it with JavaScript. –  DisgruntledGoat Jul 2 '13 at 0:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.