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
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 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,698
    Thanks
    6
    Thanked 1,011 Times in 984 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,373
    Thanks
    11
    Thanked 592 Times in 572 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/9/03) IE7:0.1, IE8:4.6, IE11:9.1, IE9:3.1, IE10:3.0, FF:17.2, CH:46, SF:11.4, NON-MOUSE:38%


  •  

    Posting Permissions

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