Hide actual url in address-bar using iframe

Posted on April 9, 2008 
Filed Under how-to, tips and technique, tutorial

Do you want to hide the actual URL in the address-bar? Do you want to display the same url throughout the website? Then here is the tips for you do the same in your website. Just display the same URL i.e http://www.your-site.com throughout your website in address bar, no matter if you in the page http://www.your-site.com/aboutus.html.


Live Demo

As you can see demo, it displays the same url throughout the browser’s address bar.But you are navigating to different page like aboutus.html or services.html. Ok, too much explanation, now let’s know how to do it.

1) First of create, all the other relavant page like “services.html” or “contactus.html” as usual.
2) For home page, rename the actual index page like “index.html” or “index.php” as “home.html” or “home.php” or whatever name you’re comfortable with.
3)Now, in the index page like “index.html” or “index.php”, put the following code

<iframe src="home.html" width="100%" height="100%" frameborder="0" scrolling="no" />

As, you can see above, we’ve used iframe to display the “home.html” page in the home page by using “src” attribute. The width and height should be “100%” and border should be ” ” for hiding the actual URL from the browser and displaying it so normal.

When a new link is clicked in the page, it gets loaded within “iframe” and displays the same URL throughout the website.

Download Full Source Code

Popularity: 13% [?]

Enter your email address and get recent tutorials, tips, tricks and scripts of PHP, Ajax, JavaScript and CSS directly delivered to you email inbox:

Follow me on twitter at http://twitter.com/roshanbh.

Related Posts

» Animated content navigation effect using jquery
» Custom Error Page with .htaccess
» 5 useful url rewriting examples using .htaccess
» How to display panel (div) only in Internet Explorer (IE)

Comments

5 Responses to “Hide actual url in address-bar using iframe”

  1. P4trykx on April 11th, 2008 10:09 pm

    There is also somtehtigs like mode-rewrite to apache that can do similiar thing.
    But is there any reason in doing so ? For me it’s like making white text over yellow background.

  2. Roshan on April 12th, 2008 6:38 am

    Well P4trykx, I respect your thought but I got around 10 emails through my contact form asking this technique to display domain name in url always. Furthermore, you are not suggested to use this technique from the SEO point of view.

    BTW I don’t think mod_rewrite can do the same thing i.e. display same url throughout the site. If you think mod_rewrite can do this then show me a example otherwise it’s very hard to believe me this…

  3. Daniel on April 13th, 2008 9:44 am

    I have a website ( as you can see) and if you look at the page you can see a logi script. (which is being upgraded to a more secure one soon). When you enter the correct details you are directed to another page. That is why i need a way to hide the contents of the address bar, security. Is there any other way of doing this than frameset?
    Thankyou, Daniel Curzon

  4. Roshan on April 14th, 2008 4:20 am

    For that you can post the values or you can put these values in session to hide the content in the address bar..

  5. Barack on July 16th, 2008 11:43 am

    this is a good trick to hide the url.

    Thanks

Leave a Reply