Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: Disable JavaScript inside an iframe

  1. #11
    Join Date
    Apr 2007
    Posts
    23
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    thanks friend let me try this out...

  2. #12
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Because of your response here, I looked over that code again and saw a potential problem. Since I wrote that, I've found cases where an empty () matches anything, so we should do it (changed section highlighted):

    Code:
    <script type="text/javascript">
    <!-- 
    if (parent != self  && !/^http:\/((\/www\.)|(\/))yourdomain\.com/.test(top.location.href)) top.location.replace(self.location.href);
    // -->
    </script>
    So instead of:

    Code:
    !/^http:\/\/((www\.)|())
    We now have:

    Code:
    !/^http:\/((\/www\.)|(\/))
    thus ensuring no empty (), without changing the intended meaning.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #13
    Join Date
    Aug 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for this code but where to place this in Iframe ?

    If i use Iframe as <iframe src="www.mydomain.com">

    Thanks

  4. #14
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    In the head of the page at:

    www.mydomain.com
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #15
    Join Date
    Aug 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    as if i have to go with some page like www.mydomain.com/index3.html then what should i write in code

  6. #16
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Same thing. What you may or may not have figured out here is that you have to have access to edit the page in the iframe. You cannot disable the javascript in the iframe from the top page unless it's on the same domain as the top page anyway, so it's easier to just tailor the code on the page in the iframe to do your bidding.

    The script in question here doesn't care what the exact name of the page is, it just tests if the domain name of the top page is the desired one. If so, the page in the iframe remains in the iframe. Otherwise, it will brake out of frames, so someone from another site cannot put it in one of their frames or iframes.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •