Bladephp: Now with 8+ codeigniter, php, and laravel project 8+ php project From $37/Month From Rs. 2499/Month

How to Change Browser URL Without Refreshing Page Using jQuery and HTML5

by
Category:jquery
jquery html
How to Change Browser URL Without Refreshing Page Using jQuery and HTML5

In this short article I will explain how to change the URL in browser without reloading or refreshing the page using HTML5 and jQuery. You have seen in many dynamic website when you request new page they dont redirect you to new page they simply change the URL and get that page using Ajax. You may also like How to get Browser name, useragent, version, platform and pattern in PHP and How to Detect User Browser JavaScript Programming.

jQuery Code

<html>
    <head>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
        <script type="text/javascript">
            function changeurl(url)
            {
                var new_url = "/Your URL/" + url;
                window.history.pushState("data", "Title", new_url);
                document.title = url;
            }
        </script>
    </head>
    <body>
        <p>Click On Languages To Change URL</p>
        <li onclick="changeurl('PHP');">PHP</li>
        <li onclick="changeurl('HTML');">HTML</li>
        <li onclick="changeurl('CSS');">CSS</li>
        <li onclick="changeurl('jQuery');">jQuery</li>
    </body>
</html>

0 Comments


Html code work in comment box


Related Post