473,806 Members | 2,248 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cannot access links in an iframe

The property document.links seems to access links inside a frame, but
not an iframe. For instance, the following code displays a "4": 2
links in main page, 2 links in frame1.
<body onload="fn()">
<script type="text/javascript">
function fn()
{
alert(document. links.length)
}
</script>

<a href="http://somewhere1">aaa </a>
<a href="http://somewhere2">bbb </a>

<frameset>
<frame name="frame1" id="frame1">
<a href="http://somewhere3">ccc </a>
<a href="http://somewhere4">ddd </a>
</frame>
<iframe name="frame2" id="frame2" src="http://somewhere5">
</iframe>
</frameset>

</body>
Is there a way to access the links in the iframe?

Thanks in advance.

May 30 '07 #1
6 2325
os**********@gm ail.com wrote:
The property document.links seems to access links inside a frame, but
not an iframe. For instance, the following code displays a "4": 2
links in main page, 2 links in frame1.

<body onload="fn()">
<script type="text/javascript">
function fn()
{
alert(document. links.length)
}
</script>
It reports exactly what is found. Now, whether or not you understand
your markup is an entirely different thing.
<a href="http://somewhere1">aaa </a>
<a href="http://somewhere2">bbb </a>

<frameset>
<frame name="frame1" id="frame1">
<a href="http://somewhere3">ccc </a>
<a href="http://somewhere4">ddd </a>
</frame>
<iframe name="frame2" id="frame2" src="http://somewhere5">
</iframe>
</frameset>

</body>
How do you expect JavaScript to behave the way you want it to if you do
not provide it valid HTML?
Is there a way to access the links in the iframe?
Yes. You must first however embed it properly in a page. For example,
in a frame, in a frameset.

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
May 30 '07 #2
Well, yes, I guessed I could be doing something wrong, but what is it?

I have skimmed trhough hundreds of examples on the net and they all
seem like mine to me.
Also, the page displays correctly.

Some more help, please?

May 30 '07 #3
On May 30, 12:13 pm, marsanos <oscar1mar...@g mail.comwrote:
Well, yes, I guessed I could be doing something wrong, but what is it?
Start with valid HTML: http://validator.w3.org/

Avoid frames: http://allmyfaqs.net/faq.pl?Problems_with_using_frames

In you insist on using frames, use them according to the standard:
http://www.w3.org/TR/html4/present/frames.html

--
David Dorward
http://dorward.me.uk/
http://blog.dorward.me.uk/

May 30 '07 #4
Now, this is a helpful answer. And a proof that there are a few things
I have to learn.

Thanks to both of you.

May 31 '07 #5
David Dorward wrote:
...
Avoid frames: http://allmyfaqs.net/faq.pl?Problems_with_using_frames

I've seen warnings on Google's site about indexing problems when using frames.
Although Google does seem to index pages using iframes without any problems as long
as you provide non-iframe support information.

Rob
www.rcp.ca

Jun 3 '07 #6
marsanos wrote :
Well, yes, I guessed I could be doing something wrong, but what is it?

I have skimmed trhough hundreds of examples on the net
Browser manufacturers, browsers and browser versions do not skimmed
through hundreds of examples on the web. What they do is read the HTML
4.01 spec and then try to follow and comply with the HTML 4.01 spec.

HTML 4.01 technical recommendation
http://www.w3.org/TR/html4/cover.html

The frameset element can only have <frame>(s), <frameset>(s) or
<noframeselemen ts. The frameset element can not have an <iframe>, like
in your posted code. That's what the HTML 4.01 spec says.

http://www.w3.org/TR/html4/present/frames.html#h-16.2.1

And this chunk of markup code (taken from your original post):
<frame name="frame1" id="frame1">
<a href="http://somewhere3">ccc </a>
<a href="http://somewhere4">ddd </a>
</frame>
is invalid.
Some more help, please?
Don't use <frame>s, don't use <framesetand don't use <iframeas these
are bad for accessibility, search/indexing, bookmarking.

With people now upgrading to newer browsers or newer browser versions
which can support position: fixed, there is no good reason anymore to
use frames. If we knew exactly what you are trying to do along with an
url, we could be able to better help you.

Gérard
--
Using Web Standards in your Web Pages (Updated Apr. 2007)
http://developer.mozilla.org/en/docs...your_Web_Pages
Jun 3 '07 #7

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

Similar topics

4
10314
by: nc | last post by:
My iterator can find my collection when my Action class calls my jsp directly, however when my Action class calls an html file that is set up with IFrames (one of which is loading that same jsp), I get a servlet error "cannot find collection". Not usre if my issue is HTML, JSP, WebSphere or ??? Any help is very much appreciated. HTML file: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
5
8820
by: chris.poirier | last post by:
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.
8
5484
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- Hello, I have a very simple problem but cannot seem to figure it out. I have a very simple php script that sends a test email to myself. When I debug it in PHP designer, it works with no problems, I get the test email. If
3
8877
by: fkater | last post by:
Hi, inside an iframe (!) I've got links with "onmouseover=" calling javascript functions. In these functions, how do I access elements from the main window? Something like document.getElementById("xyz") would of course search inside the iframe only -- however "xyz" is the Id of the body of the main window, so it is outside of the iframe. I
2
5529
by: Anthony Sporetta | last post by:
Hi all I have a page which has an iframe, containing an external site which I have no control over. When someone clicks one of their links inside the iframe, it currently opens that link also inside the iframe. Any way to make it open the link in a new window?
1
8036
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...
0
1584
Screaming Eagle
by: Screaming Eagle | last post by:
I haven't recieved any information that I could use, and researching this issue hasn't turned up any worthy results. Hence my reposting. Since I have had no reply, and my associates wish to move things along, I have been forced to use regular frames for the site (which works fine, but visually its not what I'd like to produce). Ideally, I would like to fix this problem I currently have with iframes, and do without using regular frames. If anyone...
3
2277
by: nero | last post by:
Hello group... I have a page that I'm building out that has a main area and I've used iframes in various different templates...so far so good...until now. here's the javascript: <script type="text/javascript"> function loadIframe(iframeName, url) { if ( window.frames ) { window.frames.location = url; return false;
4
3526
by: Peter | last post by:
I have the following code which works fine in IE6 and IE7 and FireFox, but when I run IE6 on Citrix I get "The page cannot be displayed" in the iframe. We don't have IE7 on Citrix so I can't try it. <span id="ShowReport" disabled="disabled" style="display:inline-block;height:1200px;width:880px;"> <div> <iframe src=../../WsiLogo.gif<frame src=../../WsiLogo.gif> <embed src=../../WsiLogo.gif</iframe> </div>
0
9718
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
10364
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10370
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
9186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7649
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
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4328
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
2
3849
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
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.