I have a test version of a site located at a subdomain of the normal site, like: http://test.x.com instead of http://x.com.
I use the <base>
tag to translate all resource requests back to the original domain:
<base href="http://x.com/" />
This tactic worked great until I implemented HTML5 push/replaceState support.
Now, if I execute this statement in the console:
history.pushState({}, "", "");
... then I get a DOMException
object in WebKit-based browsers:
code: 18
constructor: DOMExceptionConstructor
line: 2
message: "SECURITY_ERR: DOM Exception 18"
name: "SECURITY_ERR"
sourceId: 4839191928
__proto__: DOMExceptionPrototype
... and this error in FireFox 4:
Security error" code: "1000
If I remove the <base>
tag and execute the same statement, the new state is pushed, and there's no exception.
A few questions: 1) is this behavior a security risk, or is it a bug? And 2) is there a workaround to prevent the exception, or a tactic other than using the <base>
tag that will sidestep the issue completely?
Thanks for your consideration.