SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Nov 2007
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile Prevent framed windows from accessing window.parent/top

    Hi all,

    I have a website with a draggable iframe box that contains other websites (like a mini-browser). However, if the mini-browser happens to contain a page full of javascript that wants to "break out" of the frame by calling window.parent or window.top, it could ruin the entire website since the container frame is overwritten.

    Does anyone know how to prevent these children frames from overthrowing their parents with calls to window.top and window.parent? Is it possible to override, for example, window.top and window.parent such that when a child frame calls it, it effectively does nothing?

    Thanks so much for your help!

  2. #2
    SitePoint Addict
    Join Date
    Apr 2006
    Posts
    249
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't believe so, but I could be wrong. You may try doing some ajax or something to avoid being susceptible to the frame stuff.

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,834
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    It can only be done by updating the page in the iframe itself to not make that call. The containing page has no access to override it.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •