HWZ Forums

Login Register FAQ Mark Forums Read

Basic replace html tag

Reply
 
LinkBack Thread Tools
Old 24-06-2015, 06:21 PM   #1
Junior Member
 
Join Date: Feb 2015
Posts: 9
Basic replace html tag

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..
<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:
<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 by 696E20727569; 24-06-2015 at 06:38 PM..
696E20727569 is offline   Reply With Quote
Old 26-06-2015, 09:05 PM   #2
Arch-Supremacy Member
 
davidktw's Avatar
 
Join Date: Apr 2010
Posts: 10,059
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..
<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:
<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>
//a more flexible replacement using regex window.location.href.replace(/#[^?&]*/, '');
davidktw is offline   Reply With Quote
Reply
Important Forum Advisory Note
This forum is moderated by volunteer moderators who will react only to members' feedback on posts. Moderators are not employees or representatives of HWZ. Forum members and moderators are responsible for their own posts.

Please refer to our Terms of Service for more information.


Thread Tools

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On