Search code examples
javascripturlhttp-redirectmbox

fake js into thinking the url has an extra paramenter


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.


Solution

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

    Link showing an example