the_boy_za
the_boy_za

Reputation: 287

hide url in navigation bar

I have different pages and scripts on my website. I want to show 1 URL in the adressbar for all the pages.

I have pages like:

www.example.com/index.php
www.example.com/map1/index.php
www.example.com/map1/map2/index.php
www.example.com/map1/map2/map3/index.php

I want that all these URLS should be shown like: www.example.com

I have expirimented with my .htaccess script, but I cant get this working.

Can anybody help me with this problem? How can I show all the URL`s on my page like "www.example.com".

Upvotes: 1

Views: 1619

Answers (2)

user6422350
user6422350

Reputation:

Hide the Target URL of a Link in Status Bar There are some instances where you have redirect the user through one page to get them to another page. There is a way to do this stealthily - without letting the user know that there was a redirect. Yes - it sounds evil - but it don't have to be. Say you have a click tracking software - you have to track each click the users make. To do that you need a redirecting page what will track the clicks. Hopefully, the following illustration will make things clearer... Current Page->Page with the click counter->Destination Page You don't want the user to see that you are passing through the middle page. Usually, the URL will flash in the address bar for just a second(or less) - so we don't have to worry about that. We just have to prevent the URL from appearing in the status bar when the user hovers over the link. There are three methods to do this...

  • Change the status text

  • Hijack and stop the click event and redirect

    page.

  • Make an Ajax call on click event.

Changing Status Text This is the old method. This uses the window.status property to show a different URL to the user. Simple and easy method - but it rarely works now a days. This method has been abused by malicious sites a lot - so most browsers have disable this option. In Firefox, you can find that option at Tools -> Preferences -> Content -> Enable Javascript(click on the 'Advanced' Button) -> Change status bar text. If that's checked, you can use window.status to change the status bar text. But its disabled by default. But if you still want to use this method(not recommended), this is how to do it...

<a href="click_counter.php?redirect_to=http://www.google.com/" 
    onmouseover="window.status='http://www.google.com/';return true;" 
    onmouseout="window.status='';">Go To Google</a>

Hijacking Click Event In this method, when the user clicks on the link, the script captures the click event and stops it. This will prevent the browser from opening up the target page. Then we use location.href to go to the new page. Sample code below... HTML Code

<a href="http://www.google.com/" id="google-link">Go To Google</a>
Javascript Code
<script type="text/javascript">
function init()  {
    document.getElementById("google-link").onclick=function(e) {
        e=e||window.event;
        stopEvent(e);
        location.href="click_counter.php?redirect_to=http://www.google.com/";
        return false;
    }
}
window.onload=init;
</script>

Ajax Method This is for all you web 2.0 fans. Ajax method simply makes a call to the counter server side script on the click event. This is perhaps the best method of all - as the counter URL doesn't appear at all. Needless to say, the server side script used here will be different from the one used in the other methods - there is no redirection here. The code is very simple as well... HTML Code

<a href="http://www.google.com/"id="google-link">Go To Google</a>
**Javascript Code**
<script type="text/javascript">
function init()  {
    document.getElementById("google-link").onclick=function(e) {
        jx("counter.php?url="+escape("http://www.google.com/")); //Use your favorite ajax library here.
    }
}
window.onload=init;
</script>

Upvotes: 0

omghai_8782
omghai_8782

Reputation: 468

You could make www.example.com/index.php (which would be the default for www.example.com) be the only page that actually gets loaded fully, with all the others simply providing content to be loaded via ajax.

You could also make www.example.com/index.php contain only an iFrame or a frameset, such that clicks to other locations would only be to the nested frame, leaving the address bar always at www.example.com

You could also try taking "map1" and "map2" etc out of the URL and use them instead as post variables, or $_SESSION variables, or what have you.

Upvotes: 2

Related Questions