SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2004
    Location
    Cincinnati,OH
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy prevent breaking out of frame

    I have a page with frames and one of the framed pages uses:
    if (window != top) {
    top.location.href = location.href;
    }
    To force itself out of the frame. Is there a way to override this? This is for a legitimate purpose and the I have permission from other site. Ideally they could just remove the javascript but for some reason they claim it too hard to do...

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,030
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)

    frame

    This is a issue of browser control. IMHO the best thing to do is help them learn how to remove that bit of javascript for you.
    It's as simple as commenting it out. ie.
    HTML Code:
    /*
    if (window != top) {
    top.location.href = location.href;
    }
    */
    Not too complicated, is it?

  3. #3
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could turn off javascript in your browser.

  4. #4
    SitePoint Enthusiast
    Join Date
    Apr 2004
    Location
    Cincinnati,OH
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Of course the javascript isnt hard to remove or comment. Their java based website was purchased from another company and they claim the html for the site is served from some kind of java porlet or something like that. Not sure exactly im a .NET guy. Anyway i dont have access to look at their code and i cant turn of javascript since this is for not only me but customers on the website.

    Is there a way to catch the event when the framed page sets the top.location.href and just cancel it or is this impossible?

  5. #5
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,786
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    The only way to do it is to get them to modify their code.
    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="^$">

  6. #6
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,030
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)

    frame

    As I said, this is an issue of browser control. Even though your intent of doing so would be legitimate and approved, as far as any browser knows it would be browser hi-jacking. As browser hi-jacking introduces a security risk, modern browsers simply don't allow it.
    As mrhoo mentioned, you have control over your own browser. But getting all your users to turn off their javascript is less probable than getting the source to alter their code.


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
  •