location.href doesn't seem to work

C

COHENMARVIN

Folks,
I wrote a simple javascript script, but it doesn't work.
First I have a web page that uses frames:
=====================
<html>
<frameset rows="10%,90%">
<frame src="frame1.htm" name="frameName1">
<frame src="frame2.htm" name="frameName2">
</frameset>
</html>
=====================
Then within the page 'frame1', I try to have a function that fills page
'frame2'. The function is:
<script LANGUAGE="JAVASCRIPT">
function ShowSeminars()
{
/*parent.framename2.location.href = "http://www.amazon.com";*/
parent.framename2.location.href = "frame3.htm";

}
</script>
I have a button that calls the function.
But the function does not work. First I thought the reason was that it
links to outside websites, but the code doesn't even work when it links
to 'frame3.htm' (a local page).

I tried 'firefox's javascript console to tell me whats wrong, and it
says something like 'parent.framename2' has no properties.
Thanks,
Marvin
 
N

nikki

COHENMARVIN said:
Folks,
I wrote a simple javascript script, but it doesn't work.
First I have a web page that uses frames:
=====================
<html>
<frameset rows="10%,90%">
<frame src="frame1.htm" name="frameName1">
<frame src="frame2.htm" name="frameName2">
</frameset>
</html>
=====================
Then within the page 'frame1', I try to have a function that fills page
'frame2'. The function is:
<script LANGUAGE="JAVASCRIPT">
function ShowSeminars()
{
/*parent.framename2.location.href = "http://www.amazon.com";*/
parent.framename2.location.href = "frame3.htm";

}
</script>
I have a button that calls the function.
But the function does not work.

Javascript is case-sensitive.
FrameName2 != framename2

Try
parent.frameName2.location.href = "frame3.htm";
 
G

Gérard Talbot

COHENMARVIN a écrit :
Folks,
I wrote a simple javascript script, but it doesn't work.
First I have a web page that uses frames:
=====================

You should add this doctype declaration:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">


<frameset rows="10%,90%">
<frame src="frame1.htm" name="frameName1">
<frame src="frame2.htm" name="frameName2">
</frameset>
</html>
=====================
Then within the page 'frame1', I try to have a function that fills page
'frame2'. The function is:
<script LANGUAGE="JAVASCRIPT">

<script type="text/javascript">

Language is deprecated while type is both backward and forward-compatible.
function ShowSeminars()
{
/*parent.framename2.location.href = "http://www.amazon.com";*/
parent.framename2.location.href = "frame3.htm";

parent.frames["frameName2"].location.href = "frame3.htm";
}
</script>

I have a button that calls the function.
But the function does not work. First I thought the reason was that it
links to outside websites, but the code doesn't even work when it links
to 'frame3.htm' (a local page).

I tried 'firefox's javascript console to tell me whats wrong, and it
says something like 'parent.framename2' has no properties.

That means firefox does not "see" "parent.framename2" as edited. The
name is frameName2, not framename2.

Gérard
 

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

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top