473,398 Members | 2,389 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,398 software developers and data experts.

Get all tags in a famed page with IE5

I'm trying to get every tag in a page within a frameset. So far I can
get everything but IE 5 to behave by using:

// in the frame set
window.onload = function() {
mypage = window.frames['mainFrame'];
...
}

getAll = function() {
var allEl = mypage.document.getElementsByTagName(*);
...
}

The getElementsByTagName(*) fails in IE 5 so I tried

var allEl = mypage.document.all;

but, alas, it returns an error.

How can I get a collection of all tags in a page from a frameset in IE 5?
Andrew Poulos
Jul 23 '05 #1
8 1513
VK
Wrong frame addressing

frame > frameset
alert (self.top.document.all);

frame > frame
alert (self.top['mainFrame'].document.all);

frameset > frame
Locked for security issues: can be used (and it was used) to bypass
inter-domain frame security model.
So far I can get everything:
window.frames['mainFrame']; !
getElementsByT*agName(*); !

What a sorry wannaby are you using?

Jul 23 '05 #2
VK
> What a sorry wannaby are you using?

Under "wannabe" I meant a browser of course, nothing personal.

Jul 23 '05 #3
VK

In IE model frameSet doesn't have "frames" collection anymore

my bs ^ 2 (bs in square)
The only weak excuse that I did not use frames for several years by
now.

<html>
<head>
<title>Top Frameset</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script>
function test() {
//alert(self.document.title);
alert(self.frames['f2'].docume*nt.getElementsByTagName('P')[0*].innerHTML);

}
window.onload=test;
</script>
</head>

<frameset cols="50%,*">
<frame name="f1" src="frame1.html">
<frame name="f2" src="frame2.html">
</frameset>
</html>

Jul 23 '05 #4
VK wrote:
In IE model frameSet doesn't have "frames" collection anymore


my bs ^ 2 (bs in square)
The only weak excuse that I did not use frames for several years by
now.

<html>
<head>
<title>Top Frameset</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script>
function test() {
//alert(self.document.title);
alert(self.frames['f2'].docume*nt.getElementsByTagName('P')[0*].innerHTML);

Sorry, but you've confused me. In IE 5, from a frameset, instead of doing:
var mypage = window.frames['mainFrame'];
var allEl = mypage.document.all;

I should do:
var allEl = self.frames['mainFrame'].document.all;

Isn't window.frames and self.frames not the say thing?

Andrew Poulos

Jul 23 '05 #5


Andrew Poulos wrote:
I'm trying to get every tag in a page within a frameset. So far I can
get everything but IE 5 to behave by using:

// in the frame set
window.onload = function() {
mypage = window.frames['mainFrame'];
...
}

getAll = function() {
var allEl = mypage.document.getElementsByTagName(*);
...
}

The getElementsByTagName(*) fails in IE 5 so I tried

var allEl = mypage.document.all;

but, alas, it returns an error.


What kind of error? window.document.all since IE 4 gives a collection of
all elements in the document.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #6
VK wrote a bunch of nonsense, to which Andrew Poulos replied:
Sorry, but you've confused me. In IE 5, from a frameset, instead of doing:
var mypage = window.frames['mainFrame'];
var allEl = mypage.document.all;

I should do:
var allEl = self.frames['mainFrame'].document.all;

Isn't window.frames and self.frames not the say thing?
Yes, you're right, because window === self
And of course he implemented the very DOM methods that you are trying
to account for not having.

Andrew Poulos


I think I see the problem, here.

Lacking a getElementById, you're obviously being forced to use the .all
collection-- that much is readily apparent. But after fiddling with it
a bit, I was a bit miffed to note that given:
<html>
<frameset>
<frame id=frameA src=/test.html>
<frame id=frameB src=/test.html>
</frameset>
</html>
Oddly, the following will be true:
window.document.all === window.frames['frameB'].document.all
window.document.body.innerHTML ===
window.frames['frameB'].document.innerHTML
window.frames[1].all.length == 0 ???
Here was one solution (and yes, I know it's ugly, but it worked for
throwing together a quick test):

<html>
<head>
<script>

function loaded( x ) {
alert( x.body.innerHTML );
}

</script>
<frameset rows=50%,50%>
<frame src=/test.html id=frameA></frame>
<frame src=/test.html id=frameB></frame>
</frameset>
</html>
Then, in the <body> tag of /test.html, I added this:
onload=top.loaded&&top.loaded(window.document)

It worked, but it's a bad way to do it and is very easily broken.


I also found that this worked, which you may find more useful:
<html>
<head>
<script>

function check( ) {
if( window.frames['frameB'].document.readyState == 'complete' )
alert( window.frames['frameB'].document.all.length );

else
setTimeout( check, 250 );
}

</script>
<frameset rows=50%,50%>
<frame src=/test.html id=frameA onload=check()></frame>
<frame src=/test.html id=frameB></frame>
</frameset>
</html>
Apparently, until the document in frameB is actually built in the
browser, certain of its properties will refer to the parent window's
properties, in particular .all and .body

This behaviour is not at all what I would expect.

The onload in the <frame> element will fire as soon as the element is
loaded-- not necessarily the document to which it refers. The second
example above checks the referenced document's readyState every
quarter-second until it comes back as 'complete'. I'm not sure if
..readyState is implemented identically in IE4 -- you'll have to check
that.

Don't know if this information will help lead you to the specific
solution you're looking for, but hopefully it's better than nothing.

Jul 23 '05 #7
VK
Andrew & Random:

Now you guys are confusing me. Are all three of us talking about IE?
That one from Microsoft?

The code below works perfectly (just use some bogus files for
frame1.html and frame2.html). I'm using Windows XP SP1 + IE 6.0.2800

1) OnLoad fires, as it should, only after *all* frames are loaded (I
tested it on loading msn.com to the right frame, 8 sec delay before
alert).
2) No problem to access any elements in frame f1.
3) Definitely window.document.all !=
window.frames['f2'].docume*nt.all, as it's impossible.

And actually this test case equals to your OP that did *not* work for
you. I suggest to take the code below and try to bring it line by line
(checking after each change) to your current variant.
The problem is (if any) either in some extra coding you did not posted,
or in your *personal* IE.

<html>
<head>
<title>Frameset</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script>
function test() {
var win = self.frames['f1'];
var doc = win.document;
var elm = doc.all;
alert(elm[0].innerHTML);
}
window.onload = test;
</script>
</head>

<frameset cols="50%,*">
<frame name="f1" src="frame1.html">
<frame name="f2" src="frame2.html">
</frameset>
<noframes>
<body bgcolor="#FFFFFF">
<p>No frames text</p>
</body>
</noframes>
</html>

Jul 23 '05 #8
Martin Honnen wrote:


Andrew Poulos wrote:
I'm trying to get every tag in a page within a frameset. So far I can
get everything but IE 5 to behave by using:

// in the frame set
window.onload = function() {
mypage = window.frames['mainFrame'];
...
}

getAll = function() {
var allEl = mypage.document.getElementsByTagName(*);
...
}

The getElementsByTagName(*) fails in IE 5 so I tried

var allEl = mypage.document.all;

but, alas, it returns an error.

What kind of error? window.document.all since IE 4 gives a collection of
all elements in the document.

The error's solved. You guys were right: I was calling getAll before the
page had loaded. Funnily enough IE6 didn't complain.

Andrew Poulos
Jul 23 '05 #9

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

Similar topics

19
by: Christian Hvid | last post by:
Hello groups. I have a series of applet computer games on my homepage: http://vredungmand.dk/games/erik-spillet/index.html http://vredungmand.dk/games/nohats/index.html...
24
by: Day Bird Loft | last post by:
Web Authoring | Meta-Tags The first thing to understand in regard to Meta Tags is the three most important tags placed in the head of your html documents. They are the title, description, and...
2
by: Got2Go | last post by:
Hello, I am trying to come up with a function that will search the source of the page for a specific string. If that string is found, then have it modify specific tags inside of a table and...
1
by: D. Shane Fowlkes | last post by:
I'm a fairly skilled traditional ASP/VB programmer and am learning .NET. I was (recently) surprised to read in a book about declaring and defining all my page Functions in <script...
7
by: Rocky Moore | last post by:
I have a web site called HintsAndTips.com. On this site people post tips using a very simply webform with a multi line TextBox for inputing the tip text. This text is encode to HTML so that no...
2
by: ZMan | last post by:
I'm trying to format some data out as an RSS feed. I already have a perfectly good ASPX page that does the same thing with an <asp:repeater> so I figured I'd take the page change the html tags to...
23
by: Big Bill | last post by:
http://www.promcars.co.uk/pages/bonnie.php I don't believe they should be there, can I take them out without stopping the includes from functioning? I'm the (hapless) optimiser on this one... I...
10
by: Barry L. Camp | last post by:
Hi all... hope someone can help out. Not a unique situation, but my search for a solution has not yielded what I need yet. I'm trying to come up with a regular expression for a...
3
by: MikeB | last post by:
Hello, I have a content page that is from a Master page which has 2 content panes. How do I add my forms to the content page? Each pane needs a form but you can not have multiple form tags nor...
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: 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?
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
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...
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,...
0
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...
0
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...
0
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,...

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.