The main frame contains two frames ‘top’ and ‘bottom’.
Now I have an iframe inside the bottom frame. And it is linked to an external website. However, I wish to disable clicking on any of its links (both right and left) inside the iframe. Could you please tell me the code to do so.
Ps: I am an utter newbie to webpage development or programming.
Left clicking on something and using the keyboard to give that something the focus and then pressing enter are two of many ways to achieve the same result. There is no way of writing anything that will block all of the different ways and even if you do your visitors will be able to reneable the functionality if they want to.
Right clicking brings up the context menu the same as the contextmenu button on the keyboard does (the key between the right windows and ctrl keys). Modern web browsers don’t allow you to block this function and where it is allowed the person visiting your page can always re-enable it. Also all of the options in that menu are also available from elsewhere in any case.
You should design your page so that it doesn’t matter if people click rather than wasting time blocking newbie web users from some of the options that they use to navigate the web - and hence driving them away from your site - while not impacting on experienced web users at all.
Normal users hate it when web sites interfere with the normal functioning of their browser because they end up being unable to use the options that they normally use to navigate between sites.
Why not design the iframe content so that it functions the way that you want it to in the first place rather than trying to override functionality after the page has displayed.
I’m with felgall on this one, but we don’t know what your use for it is, so…
I guess a very rough and dirty way could be to position a transparent gif over the iframe. It would still give you a right click, but for the image and any links on the page in the iframe would not be clickable.
I’ve no idea if it would actually work as i’m thinking, but it’d be worth a try.
I usually try to give answers that help the person achieve the desired result rather than necessarily answering the particular question that is asked. Most times when people ask about disabling mouse clicks it has to do with attempting to protect content - which can’t be done. If you tell us why you think blocking the mouse buttons is required I can probably tell you what you should be doing instead.