Issue
I am new to HTML so this question might sound a bit lame. Anyways I have a saved webpage on my desktop that when i open it in google chrome i want it to show a specific URL instead of its current location. Any ideas how i might get this to work? I tried using the history.pushState but i have no idea why it is not working. I created a simple page for now to test it:
<html>
<head>
<script>
function setURL()
{
history.pushState("Test","page2", "www.test.com");
}
</script>
</head>
<body>
<button type="button" onclick="setURL()">Set Url</button>
</body>
</html>
Any help would be greatly appreciated. Thank you
Solution
I think you've misunderstood how it works. It's used to change the page location, without reloading the content, on the same domain. For example: you're on the index. Then you click the "about" page, it will change the url from www.hello.com
to www.hello.com/about
.
With additional JS in use, you could make it load the changes to make it look like the about page without loading the entire thing (but this is unrelated to what you want; just explaining an application for it.)
It does not allow for complete URL overwriting and your desktop file is not considered to be the same domain as your website (security limitation).
If this is to fool someone: you won't be able to do it.
Answered By - Rhyono
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.