Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy just confused really

    ok im trying to get to know web design/ coding and have just started looking at javascript i have looked at a few tutorials and looked at a few sites source containing javascript..
    i tried to recreate a simple enough search box which has a query box then you click which site to search and then the submit button which then loads the search page in a frame beside the box but when i recreated it and clicked submit there was an error

    'parent.frames.1.location' is null or not an object

    i dont have any additional frames added on the page and would like to know what i should do and what the parent.frame.1 is

    any help is much appreciated


    below is the code i have so fa... very simple


    <html>
    <head>
    <script language="Javascript" type="text/javascript">
    function search()
    {
    if (document.f.q.value == "")
    {
    var URL;
    if (document.f.engine[0].checked) { URL = "http://www.google.com/" }
    if (document.f.engine[1].checked) { URL = "http://www.msn.co.uk/" }
    parent.frames[1].location.href=URL;
    }
    else
    {
    var URL;
    if (document.f.engine[0].checked) { URL = "http://www.google.co.uk/search?hl=en&q=" + document.f.q.value; }
    if (document.f.engine[1].checked) { URL = "http://search.msn.co.uk/results.aspx?FORM=MSNH&CP=1252&q=" + document.f.q.value; }
    parent.frames[1].location.href=URL;
    }
    }
    </script>
    </head>

    <body onload="javascript:document.f.q;">

    <form action="javascript:search();" name="f"><br>
    <input name="q" style="width: 140px;" type="text">
    <input name="engine" value="1" class="blank" type="radio" checked="checked" id="s1"><label for="s1"> Google</label><br>
    <input name="engine" value="2" class="blank" type="radio" id="s2"><label for="s2"> MSN</label><br>

    <input value="Torrent Search" class="flat-button" style="position: relative; top: 5px; width: 90px;" type="submit">
    </form>

    </script>
    </body>
    </html>
    Last edited by holyhell81; 07-05-2005 at 06:02 PM.

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Change the 2 instances of this line

    parent.frames[1].location.href=URL;

    to this

    location.href=URL

    Also take out the

    onload="javascript:document.f.q;"

    from the opening BODY tag

    You could also take out the second

    var URL;

    and put the first before the function line
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •