Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Feb 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Is there a way to overide this javascript externally?

    Hi

    I'm a complete numpty when it comes to javascript so please excuse my ignorance.

    I have a link to a site that I usually open in an iframe, the source of that site now contains this code...

    <script type="text/javascript">if(top.location.href!=self.location.href)top.location.href=self.location.href;</script>

    Which unless I am mistaken means "Get the hell out of any frames"

    Is there anything that I can do in my iframe code to overide that and force the site into my iframe or will javascript always win this battle?

    Thanks in advance

    Steve

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,928
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Fortunately, Javascript will always win the battle.

    The site you refer to does not wish you to load it into your iframe. Period.

    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

  • #3
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,642
    Thanks
    6
    Thanked 1,005 Times in 978 Posts
    Well, the only way to win a battle over JavaScript is to disable it.

  • #4
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by VIPStephan View Post
    Well, the only way to win a battle over JavaScript is to disable it.
    on the server side?

    best regards

  • #5
    Gütkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    You can use the onbeforeunload event to at least give the user a chance to cancel the redirection. But probably you just shouldn't embed the site in yours, since their owner obviously doesn't want you to.

  • #6
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,302
    Thanks
    10
    Thanked 586 Times in 567 Posts
    once upon a time you could use <object> instead of <iframe>, but i don't know if that trick still works...
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%


  •  

    Posting Permissions

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