Problem with location.href and frames

A

August Karlstrom

Hi everyone,

I have some problems loading a page into a frame from a different frame.
In Firefox and Explorer the lower frame displays "Test..." but in some
older version of Safari it is left blank. Can anyone spot undefined
behavior in the documents below or should we blame Safari?


Regards,

August


=== index.html ===

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html>
<head>
<title>Test</title>
</head>
<frameset rows="50%, *">
<frame src="frame0.html" />
<frame />
</frameset>
</html>


=== frame0.html ===

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title></title>
</head>
<body onload="parent.frames[1].location.href = 'frame1.html'">
<p>If the lower frame shows "Test..." the page is correctly displayed.</p>
</body>
</html>


=== frame1.html ===

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title></title>
</head>
<body>
<p>Test...</p>
</body>
</html>
 
A

August Karlstrom

Randy Webb skrev:
August Karlstrom said the following on 3/11/2007 5:36 PM: [...]
<body onload="parent.frames[1].location.href = 'frame1.html'">

I never cared for parent.frames unless it is a nested frameset.
window.frames[1]

Or, you could try giving the frame a NAME attribute:

window.frames['frameNAME']

After changing the line

<body onload="parent.frames[1].location.href = 'frame1.html'">

to

<body onload="window.frames[1].location.href = 'frame1.html'">

Firefox gives me the error

window.frames[1] has no properties


August
 
R

Richard Cornford

August said:
I have some problems loading a page into a frame from a
different frame. In Firefox and Explorer the lower frame
displays "Test..." but in some older version of Safari it
is left blank. Can anyone spot undefined behavior in the
documents below or should we blame Safari?
<frameset rows="50%, *">
<frame src="frame0.html" />
<frame />
</frameset>
<body onload="parent.frames[1].location.href = 'frame1.html'">
<snip>

If the frame at index 1 has no SRC attribute what is the URL of whatever
is loaded into it? And then what is the absolute URL that results from
then assigning its location the relative URL "frame2.html", given that it
may be relative to the URL of whatever was loaded into the frame with the
index of 1?

Richard.
 
A

augukarl

August Karlstrom wrote: [...]
<frameset rows="50%, *">
<frame src="frame0.html" />
<frame />
</frameset>
<body onload="parent.frames[1].location.href = 'frame1.html'">

<snip>

If the frame at index 1 has no SRC attribute what is the URL of whatever
is loaded into it? And then what is the absolute URL that results from
then assigning its location the relative URL "frame2.html", given that it
may be relative to the URL of whatever was loaded into the frame with the
index of 1?

Well, changing to

<frameset rows="50%, *">
<frame src="frame0.html" />
<frame src="dummy.html" />
</frameset>

makes no difference.

What would you suggest?


August
 
T

Tom Cole

August Karlstrom wrote: [...]
<frameset rows="50%, *">
<frame src="frame0.html" />
<frame />
</frameset>
<body onload="parent.frames[1].location.href = 'frame1.html'">

If the frame at index 1 has no SRC attribute what is the URL of whatever
is loaded into it? And then what is the absolute URL that results from
then assigning its location the relative URL "frame2.html", given that it
may be relative to the URL of whatever was loaded into the frame with the
index of 1?

Well, changing to

<frameset rows="50%, *">
<frame src="frame0.html" />
<frame src="dummy.html" />
</frameset>

makes no difference.

What would you suggest?

August- Hide quoted text -

- Show quoted text -

Have you tried using top:

<body onload="top.frames[1].document.location.href = 'frame1.html';">

I don't have Safari or I would have tested for you.
 
R

Richard Cornford

August Karlstrom wrote: [...]
<frameset rows="50%, *">
<frame src="frame0.html" />
<frame />
</frameset>
<body onload="parent.frames[1].location.href = 'frame1.html'">

<snip>

If the frame at index 1 has no SRC attribute what is the URL of
whatever
is loaded into it? And then what is the absolute URL that results from
then assigning its location the relative URL "frame2.html", given that
it
may be relative to the URL of whatever was loaded into the frame with
the
index of 1?

Well, changing to

<frameset rows="50%, *">
<frame src="frame0.html" />
<frame src="dummy.html" />
</frameset>

makes no difference.

What would you suggest?

1. Assign the URL to the frame's - location - property directly and not
the -href - property of the location object.
2. Replace the pseudo-xhtml mark-up with valid HTML (so there will be no
issues with inconsistent error-correction as the browsers attempt to
tag-soup your mark-up into an object model).
3. Give the FRAME elements NAME attributes and corresponding IDs
attributes and reference the pertinent frame as a named member of the -
frames - collection rather than by numeric index.

Richard.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,132
Latest member
TeresaWcq1
Top