696E20727569
Junior Member
- Joined
- Feb 25, 2015
- Messages
- 9
- Reaction score
- 0
Hi, I'm trying to figure how it works to do a replace in html tag before I learn how to replace html hash tag..
I am aiming to work on futher -stackoverflow.com/questions/269044/remove-fragment-in-url-with-javascript-w-out-causing-page-reload
So I could not get my basic to replace the tag on the address bar.. please guide..
The actual stuff is that I wanna work on #replacement if anyone knows this. Please share:
I am aiming to work on futher -stackoverflow.com/questions/269044/remove-fragment-in-url-with-javascript-w-out-causing-page-reload
So I could not get my basic to replace the tag on the address bar.. please guide..
HTML:
<head>
<script>
function myFunction(){
var stateObj = { foo: "bar" };
history.pushState(stateObj, "page 2", "bar.html");
}
</script>
</head>
<body onload="myFunction()">
</body>
The actual stuff is that I wanna work on #replacement if anyone knows this. Please share:
Code:
<script>
window.location.replace("#");
// slice off the remaining '#' in HTML5:
if (typeof window.history.replaceState == 'function') {
history.replaceState({}, '', window.location.href.slice(0, -1));
}
</script>
Last edited: