Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Html5 coming with Pushing n Popping feature .. and more easy to manipulating browser using this command ..

var stateObj = { foo: "bar" };
history.pushState(stateObj, "page 2", "bar.html");


example from this Mozilla.org
but i trying to replace bar.html using another url website like http://youtube.com .. it stuck and i can't goes to destination ..
how to do that .. please help me .. thanks

What I have tried:

<pre>var stateObj = { foo: "bar" };
history.pushState(stateObj, "page 2", "bar.html");
Posted
Updated 25-Jan-18 8:54am

You can't do this for security reasons

Manipulating the browser history - Web APIs | MDN[^]

Quote:
The new URL must be of the same origin as the current URL


Please don't ask how it can be done anyway, or is there another way of doing this, it should be fairly obvious why the browser won't let you pretend to be another site.
 
Share this answer
 
Comments
Khabibb Mubarakk 25-Jan-18 19:44pm    
thanks for it
Quote:
How to manipulating browser histori using pushstate HTML5

Short answer: you don't.
Webapps are not allowed to change things on client side. Otherwise, how long would it take to malware to abuse the feature ?
 
Share this answer
 
Comments
Khabibb Mubarakk 25-Jan-18 19:44pm    
thanks for it

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900