473,387 Members | 1,882 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 2287
os**********@gmail.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...@gmail.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
<noframeselements. 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
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...
5
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
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 -------------------------------------------------------------------------------- ...
3
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 ...
2
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...
1
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...
0
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...
3
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...
4
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.