Hide actual url in address-bar using iframe

Advertisement

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

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

15 Comments on “Hide actual url in address-bar using iframe”

  • P4trykx wrote on 11 April, 2008, 22:09

    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.

  • Roshan wrote on 12 April, 2008, 6:38

    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…

  • Daniel wrote on 13 April, 2008, 9:44

    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

  • Roshan wrote on 14 April, 2008, 4:20

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

  • Barack wrote on 16 July, 2008, 11:43

    this is a good trick to hide the url.

    Thanks

  • richiebee wrote on 10 November, 2008, 23:07

    can’t see the code above the following code

  • ned wrote on 16 December, 2008, 16:09

    The code hides the URL when you click on the link, but not when you put the mouse on the link. Give it a try and put the mouse on one of the link and you will see the URL changing on status bar.

  • Roshan wrote on 17 December, 2008, 9:53

    ya true…..you can see the actual URL in the status bar ….for that you can look at this post…

    http://roshanbh.com.np/2008/08/different-status-bar-text-hyperlink-mouseover.html

  • James Young wrote on 23 March, 2009, 22:49

    Suppose i have a link http://www.website1.com/xyz , if user clicks on this link i want to display in address bar as http://www.website2.com/xyz .. Is it possible ?

    Thanks for the help !

  • Arun Rathod wrote on 4 December, 2009, 6:54

    Guys, I need your help. I have some people working on a website. Now I dont want the to know the URL of that website in the address bar, and also dont want them to navigate to any other page. So I dont have any solution for that.
    What i think is to keep that webpage on the homepage of the web browser and than delete the navigation tool bar completely. Can I do that? Or do you have anyother solution for my problem. Please replay soon.

  • mrkhan wrote on 17 April, 2010, 11:22

    hi, this is best trick… thanks for that…

  • Bharat Patel wrote on 19 July, 2010, 5:52

    Hey this is exactly what i was looking for.

    I had been facing this problem but unable to find the way out.

    Thanks a lot for that.

  • mac wrote on 11 August, 2010, 13:57

    Perfect…. exactaly what i needed. Thanks!

  • sandeep pathak wrote on 25 April, 2012, 10:41

    perfect…….
    thanks u alot…………………………..

  • Dustypython web design wrote on 7 May, 2012, 21:11

    Hi Perfect for my web site client area preview section. Clients are able to test there sites before going live. The only problem I have is that the 100% height will not work so I have had to put a large pixel figure in, apart from that it’s just what I was looking for. never gave iframe a second thought.

    Thanks good work………..

Write a Comment

 


Copyright © 2014 Roshan Bhattarai's Blog. All rights reserved.
Powered by WordPress.org, Custom Theme and ComFi.com Calling Card Company.