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
    • 717
    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.

    <script type="text/javascript">
    
        function ChangeUrl(title, url) {
            if (typeof (history.pushState) != "undefined") {
                var obj = { Title: title, Url: url };
                history.pushState(obj, obj.Title, obj.Url);
            } else {
                alert("Browser does not support HTML5.");
            }
        }
    
    </script>
    
    <input type="button" value="Page1" onclick="ChangeUrl('Page1', 'Page1.htm');" />
    <input type="button" value="Page2" onclick="ChangeUrl('Page2', 'Page2.htm');" />
    <input type="button" value="Page3" onclick="ChangeUrl('Page3', 'Page3.htm');" />
    <input type="button" value="Page4" onclick="ChangeUrl('Page4', 'Page4.htm');" />
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: