Question

i have a script included into my site that reads a variable on the url like www.test.com/?mboxDisable=1 so i was wondering how to fake that so on www.test.com js would "think" there is mboxDisable=1 I know coldfusion and i could that by just using on the first line but how to do that with js? I tried the document.location.href += "mboxDisable=1" but then js refreshes the page to www.test.com/?mboxDisable=1 Is there a way to make js think that the parameter in the url without actually being in the url?

I forgot to mention the usage: I have a cookie that i check to see if the user wants to disable mbox or not so in pseudo code would be something like if cookieIsSet urlAppend("mboxDisable=1") endif

The auto generated code that i can't change gets the info from document.location. any way to edit that without refreshing the page? No html5 and no jquery. Can use coldfusion and js.

Was it helpful?

Solution

Use HTML5 pushState using which the URL of the page can be modified without refreshing the page.

Link showing an example

OTHER TIPS

Use a URL hash instead of a parameter:

mysite.com?mboxDisable=1 becomes: mysite.com#mboxDisable=1

You can then use document.location.hash to both read and set this parameter without refreshing. Of course your code will need to be able to read this value instead.

All other methods to change the URL will result in loading a new page.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top