Wednesday, November 4, 2009

Hide URL in address bar using iframe (code that works)

I've been searching Google for some time, and I expected to find the answer easily, but that was not the case. So I wrote it here.
The following will show Yahoo home page in an iframe, but the URL in the address bar will be yours, and it stays the same, even if the user clicks on some link and go to another site.
If you ever tried to create an iframe, you noticed that you have two scroll bars - one of the page and one of the iframe. Well, the following code solves that too. The piece of code that most people are looking for is marked in red.

<html>
<head>
<style type="text/css">
html {
overflow: hidden;
}
</style>
</head>
<body>
<iframe name='FRAME1' src='http://www.yahoo.com' width='100%' height='100%' marginheight='0' marginwidth='0' scrolling='auto' frameborder='0'>
<p>Your browser does not support iframes.</p>
</iframe>
</body></html>

28 comments:

  1. This is brilliant!One more question: How do u hide the url in the browser status bar on mouse hover or click?

    Regards,
    Shayne
    shayne.alvares@gmail.com

    ReplyDelete
  2. awesome..!!! really helpful..TQ!!

    ReplyDelete
  3. Wow! this is simply superb. I hv been searching on google for this.
    But at last your code helped me alot.
    All the best and keep going.

    ReplyDelete
  4. How about an online site. How do you implement this?

    ReplyDelete
  5. Thousand thanks for sharing, this small piece of code is just the lifesaver to me.

    Thumb up and all the best

    ReplyDelete
  6. yeah i got the code but what should i do with it????? should i paste it any where or???

    ReplyDelete
  7. it didnt work on Chrome or Safari for me!!!

    ReplyDelete
  8. Is it possible to disable the url in iframe..?

    ReplyDelete
  9. hows that possible????????????????

    ReplyDelete
  10. i tried this code but did not worked :(
    It's not showing the Url I mentioned ...

    I merged it in my html code..but had no error but still showing the original URL in browser :(
    thx

    ReplyDelete
  11. will it work for blackberry html5 apps also for Bb 7.0 OS and 10 OS ?

    ReplyDelete
  12. Any body answer will it really work for web applications (HTML5 apps) for Nokia and Blackberry too

    ReplyDelete
  13. Then what is the config.xml

    ReplyDelete
  14. Thanks a ton. It works brilliantly!!

    ReplyDelete
  15. Some websites use script to detect iframe embedding like this and break the page loading if they found. But most of the sites would display w/o any complaints. Great examples!

    ReplyDelete
  16. This comment has been removed by the author.

    ReplyDelete
  17. Can you do the same for the status bar also?
    Hide status bar..?

    ReplyDelete
  18. It doesn't hide the url in addressbar

    ReplyDelete
  19. "Code that works" - not here :|.
    Could you maybe comment on these issues? Did we do something wrong? What could be the reasons? If you could point us in the direction where the issues lie, that would be enough.

    ReplyDelete
  20. Its useless??
    How come people says it works.It shows the url in source code.Or I came seeking in wrong place?

    ReplyDelete
  21. This comment has been removed by the author.

    ReplyDelete
  22. try this code (dont miss add iframe tag in the first and last )

    width="100%" height="520" scrolling="no" frameborder="0" allowtransparency="true" src="http://tinyurl.com/hgh9ogx"

    ReplyDelete
  23. fuck dis shit, check meh out on pronhub.com

    ReplyDelete
  24. awesome thanks for share this
    yaar

    ReplyDelete
  25. It's 2021 now, and most sites will use mechanisms to avoid being embedded in an iFrame. Your article is correct for 2009, but not for 2021. Sorry! :-)

    ReplyDelete