By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,474 Members | 1,267 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,474 IT Pros & Developers. It's quick & easy.

JavaScript - block links on iframes

P: 1
Ok, this post is not really a question, but I didn't find a way to reply on an existent post. Javascript is NOT needed, anyway it can be disabled by the user. So this is THE UNIVERSAL solution (to my question...!):

Expand|Select|Wrap|Line Numbers
  1. <div class="positioner"  style="width:402px;height:302px;border:none;margin:50px auto">
  2.     <iframe src="thelinker.html" style="position:absolute;width:400px;height:300px;border:1px solid #222;overflow:hidden"></iframe>
  3.     <div style="position:absolute;width:400px;height:300px;border:1px solid #fff;background:#fff;opacity:0.001"></div>
  4. </div>
  5.  
  6. <div class="positioner" style="width:402px;height:302px">
  7.     <iframe src="thelinker.html" style="position:absolute;width:400px;height:300px;border:1px solid #222;overflow:hidden"></iframe>
  8.     <div style="position:absolute;width:400px;height:300px;border:1px solid #fff;background:#fff;opacity:0.001"></div>
  9. </div>
  10.  
To work, absolutely you have to decide the size of the iframe. In this case 400 x 300 (px) + 1px of border.

The "positioner" is needed to know the origin of iframe.

Opacity property is needed for IE. Else nothing will work.

I tested it on all major browser but I can't know about IE < 8.
Oct 23 '12 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.