Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Change Browser URL without reloading using JavaScript

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 726
    Comment on it

    This will change the browser without refreshing and reloading page. In this code I have used four buttons for calling a function to changeUrl concurrently this function will also accepts the page Title and URL as parameters . Below is the example using HTML5 and JS.

    1. <script type="text/javascript">
    2.  
    3. function ChangeUrl(title, url) {
    4. if (typeof (history.pushState) != "undefined") {
    5. var obj = { Title: title, Url: url };
    6. history.pushState(obj, obj.Title, obj.Url);
    7. } else {
    8. alert("Browser does not support HTML5.");
    9. }
    10. }
    11.  
    12. </script>
    13.  
    14. <input type="button" value="Page1" onclick="ChangeUrl('Page1', 'Page1.htm');" />
    15. <input type="button" value="Page2" onclick="ChangeUrl('Page2', 'Page2.htm');" />
    16. <input type="button" value="Page3" onclick="ChangeUrl('Page3', 'Page3.htm');" />
    17. <input type="button" value="Page4" onclick="ChangeUrl('Page4', 'Page4.htm');" />

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: