473,791 Members | 2,711 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Blocking iframe links?

Does anyone know how I could make an iframe so that the links in the
frame page are disabled ... or if this is possible?

Any help is appreciated.

Jul 27 '05 #1
5 8819
ASM
ch***********@g mail.com wrote:
Does anyone know how I could make an iframe so that the links in the
frame page are disabled ... or if this is possible?

Any help is appreciated.


you can try to target them in a blank page ?

<iframe target="_blank"

(not tested)

--
Stephane Moriaux et son [moins] vieux Mac
Jul 27 '05 #2
ch***********@g mail.com wrote:
Does anyone know how I could make an iframe so that the links in the
frame page are disabled ... or if this is possible?

Any help is appreciated.

Assuming you have zero control over the content of the iframe, you can
cover it with an invisible div. Compatibility varies-- some browsers (I
can't remember which) have problems showing a div on top of an iframe.
In some browsers, whitespace may be considered to not be there-- get
around this by filling the invisible div with an invisible image.

Of course... then they can't click on anything in the iframe.

If the iframe is not under your control but IS on the same domain, you
can loop through its links
for( var c = 0; c < document.links. length; c++ )

And set their onClick to return false.
document.links[ c ].onclick = function () { return false; }

The problem is that anything other than links can also have an event
handler that does something similar to a link, such as:
<font class=looksLike Link
onclick="locati on.href = 'somepage.html' ;"clicks like link</font>


Jul 28 '05 #3
<ch***********@ gmail.com> wrote in message news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
Does anyone know how I could make an iframe so that the links in the
frame page are disabled ... or if this is possible?

Any help is appreciated.

Try this function (in the parent document). It is set to act upon the first iframe.
I cannot work if the iframe's document is from a different domain.

<SCRIPT type='text/javascript'>

function zapIframeLinks( idx)
{
var ifl;

if(window.frame s && window.frames[ idx ] && window.frames[ idx ].document.links )
{
ifl=window.fram es[ idx ].document.links ;
for(var i=0; i<ifl.length; i++)
ifl[i].onclick=functi on () { return false; }
}

}
window.onload=f unction(){ zapIframeLinks( 0 ) };

</SCRIPT>

--
Stephen Chalmers
547265617375726 520627572696564 206174204F2E532 E207265663A2054 51323437393134

Jul 28 '05 #4
Zif
ch***********@g mail.com wrote:
Does anyone know how I could make an iframe so that the links in the
frame page are disabled ... or if this is possible?

Any help is appreciated.


It may be obvious, but remember that any 'blocking' based on JavaScript
will fail if/when JavaScript is disabled.

--
Zif
Jul 28 '05 #5
thanks.

This worked almost perfectly, except for mailto: links ... but that
might be due to my WebMail Compose Firefox extension.

Jul 28 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1623
by: Treetop | last post by:
I have code that works in IE but not Netscape 7+. This code allows me to have a list of links that bring up an image and description in an iframe. This works great in IE, however I have users that are Netscape users. main page: var links=new Array();
38
3403
by: Emmett | last post by:
I have a simple jacascript that randomizes the background of the top frame of my webpage http://www.duke.edu/~efn. For some reason, my Internet Explorer started blocking the background and displaying this instead: http://www.duke.edu/~efn/pic.jpg. This problem didn't used to occur, and it doesn't happen on Firefox. Is there some way I can alter the script of the top frame http://www.duke.edu/~efn/top.html to prevent this from happening?...
7
3701
by: Patrick.O.Ige | last post by:
Can i use Frameset in ASP.NET?What are other options I have a question :- I have an asp.net page and i'm using TreeView control as links The links are on the left side of the page inside a iframe! I used iframe b-cos the links are too long and they shift the page to the right. Is there a way that if a user clicks a link on the Treeview it can target to the table of the main window on the right (I DOUBT IF ITS POSSIBLE) What other ways are...
3
1810
by: ESmith | last post by:
I've written a website that works fine when the user types in the URL into a browser window. Now, one of our clients, whose website has a left panel "iframe" menu, put our site in as a link and my site no longer works corrected. My site uses Session variables and response.redirects. Is there something about being run in an iframe that will mess up my site - is this an known issue? TIA
4
2560
by: Drew | last post by:
This might beyond the scope of this group because it deals with SharePoint, but I'm not sure if I can't get it to work because of SharePoint or because JavaScript is weird (I don't have much experience with JavaScript). Anyway, here is the code i'm working with. Basically, it creates appends a hidden IFrame to the page, gets the links from the IFrame, and displays those which have the "OnLink" property. The weird thing is that when I...
2
3282
riptide2049
by: riptide2049 | last post by:
I really have a problem here. I have a code that is suppost to take the href of a link from the right class;value of a link maked toreturn false. the value is a Media file the file is sent to quicktime or windows meida player depending on which plugin was found. after the plug in is found a iframe with the right player is created. here is the code. for some reason In IE the plug in doesnt work and in fire fox it crashes <!DOCTYPE html...
1
8035
by: Sura | last post by:
Hi I have a flash interactive window which has html links and this appears on an html page. This window can be moved with the mouse on the html page. The html page has an iFrame too. When the flash window comes above the iframe area the html links stop working. Yet the links remain active when the flash window is outside the iFrame area. This problem is coming in Firefox, but running fine in IE. If anybody has any solution, please...
2
1172
by: borjok | last post by:
you see its like this: i have an index page with an iFrame; links from the index page are targeted to that iframe. the iFrame sources come from 8 other static pages containing different tables..the tables are actually time schedules so they just vary by a couple of hours...i need a script that will allow me to use just 1 table and rotate the contents around is this anywhere near possible?
1
1543
by: CJ4R | last post by:
Have an issue with an iframe in FF blocking links in a z-index layer behind the layer containing the iframe. It works in IE. I can't change the layer index of the iframe because it's content needs to be on top all the time. Whenever the user mouseovers that iframe content it should expand to full size. I haven't figured out how to change the height of the ifrmae from Doc2. It should be something like... ...
0
9669
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9515
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10154
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9993
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5430
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4109
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2913
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.