Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
Node is saved as draft in My Content >> Draft
  • Change Browser URL without reloading using JavaScript

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

    Hii , the html markup consists of 4 buttons which make a call to a function change our URL. This function accepts the page Title and URL as parameters. In frist checks whether browser supports HTML5 and if yes then a state object containing the page Title and URL is created and is passed to the HTML5 History pushState method along with the page Title and URL as the other two parameters.

    <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');" />
    
    HTML5 javascript

 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: