location.href doesn't seem to work

Discussion in 'Javascript' started by COHENMARVIN, Oct 11, 2005.

  1. COHENMARVIN

    COHENMARVIN Guest

    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
    COHENMARVIN, Oct 11, 2005
    #1
    1. Advertising

  2. COHENMARVIN

    nikki Guest

    COHENMARVIN wrote:
    > 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";
    nikki, Oct 11, 2005
    #2
    1. Advertising

  3. 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">


    > <html>


    <head><title>Showing seminars</title>

    > <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>


    </head>

    > 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
    --
    remove blah to email me
    Gérard Talbot, Oct 12, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Leon
    Replies:
    1
    Views:
    10,188
    Boban Dragojlovic
    Jun 24, 2003
  2. saiho.yuen
    Replies:
    3
    Views:
    416
    kaeli
    Sep 14, 2004
  3. Replies:
    2
    Views:
    457
  4. Alex Bird
    Replies:
    3
    Views:
    175
    Thomas 'PointedEars' Lahn
    May 9, 2008
  5. menkaur

    window.location doesn't seem to work

    menkaur, Nov 28, 2009, in forum: Javascript
    Replies:
    8
    Views:
    269
    Thomas 'PointedEars' Lahn
    Nov 28, 2009
Loading...

Share This Page