April 6, 2012

Hide anchor tag from url

Question by soft_developer

Possible Duplicate:
How to hide anchor tag from URL

I have a menu which contains submenus, I want that onclick if each submenu, that will redirect me on a div of the php page :

For example if I want to go from :

Menu Menu1 –> Submenu1 I want that onclick of my sbmenu1 it redirect my on a div on page1#div_name without dipslay on the URL : www.page1.php#div_name, I just want www.page1.php

    <ul>
        <li><a href="#">Menu1</a>
            <ul>
                <li><a href="page1.php#div_name">Submenu1</a></li>
                <li><a href="page2.php#div_name">Submenu2</a></li> 
            </ul>
        </li>
    </ul>

How can I fix this?

Answer by Starx

You can modify the URL after it completes loading

window.history.pushState(“object or string”, “Title”, “page.php”);

FOr more info, check this tutorial.

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!