dcsimg
www.webdeveloper.com
Results 1 to 11 of 11

Thread: I tried using onclick to break out of frames and doesn't work.

  1. #1
    Join Date
    Mar 2003
    Posts
    26

    I tried using onclick to break out of frames and doesn't work.

    I had a perfectly good method of breaking out of frames but when I tried to trigger it using onclick the think can not find the object parent.window.realchoices.location. Here is what I did:
    function closeHelp() {
    top.location.href=parent.window.realchoices.location.href;

    }
    "the above is in a set of script tags"
    <a href="javascript://" target="_top" onclick="javascript:closeHelp()" alt="Press alt plus Q and then enter to quit help" accesskey="Q" title="Close" > <img src="x.jpg" width="16" height="16"> </A>
    I tried many variations and it won't work. My original method worked like a dream.
    <a href="javascript:location.href=parent.window.realchoices.location.href" target="_top" alt="Press alt plus Q and then enter to quit help" accesskey="Q" title="Close" > <img src="x.jpg" width="16" height="16"> </A>
    My boss encourgaed me to use onclick but it just won't work. for some reason.

  2. #2
    Join Date
    Jan 2003
    Location
    Texas
    Posts
    10,413
    You can either use href="javascript:closeHelp()" or onClick="closeHelp()" but onClick="javascript:closeHelp()" is not acceptible.

  3. #3
    Join Date
    Mar 2003
    Posts
    26
    Yeah, I orignally did that, I just put in onclick="javascript:closeHelp()" just for the hell of it.
    I shouldn't be doing that but sometimes trying everything you can think of really does work. What I put origninally and what i should have kept is
    onclick="closeHelp()" but I assure you it has nothing to do right now with whether it will work not because it doesn't.
    Sorry if I screwed anyone up reviewing my code. Thanks for your help.

  4. #4
    Join Date
    Mar 2003
    Posts
    26
    I brought this up again because I am still having problems with it and I really like to know why it is not working. The javascript works inline as href="javascript:location.href=parent.real_choices.location.href;" but I know that is very bad idea so I instead want to put it in a function.
    <script language="JavaScript1.2" type="text/JavaScript1.2">
    function closehelp() {
    top.window.location.href=parent.real_choices.location.href;

    }
    Then I use onclick.

    <a href="demo.htm" onclick="quit(); return false" title="Close Help ALT Q" accesskey="q" >
    This the code that I keep coming back to and should be the way to do it correct. So can anyone help me please. No matter how hard I try it does not work for me. It seems like the javascript isn't even attempted for some reason it just tries to go to whatever I put in the href. Thanks.

  5. #5
    Join Date
    Jan 2003
    Location
    Texas
    Posts
    10,413

    <a href="default.htm" onClick="top.location.href=parent.real_choices.location.href; return false;">


    [J]ona

  6. #6
    Join Date
    Mar 2003
    Posts
    26
    Is there no way to do it in a function. If you know that it won't work and it isn't just me please let me know. Thanks.

  7. #7
    Join Date
    Jan 2003
    Location
    Texas
    Posts
    10,413

    <script type="text/javascript">
    function redir(){
    top.location.href=parent.real_choices.location.href;
    return false;
    }
    </script>

    <a href="page.html" onClick="redir();"></a>


    [J]ona

  8. #8
    Join Date
    Mar 2003
    Posts
    26
    I tried you script basically copied everything in there and it still will not work. Even worse I find that if I make it access <a href=" top.location=parent.real_choices.location.href" just as a test and it won't work it ignores the javascript and treats it like a link. I am using ie 6.0 and it is on a IIS5.1 server. It only seems to work when i put out that target is that proper behavior, i havbe had other machines look at it and browsed it on netscape, same behavior. Is this standard behavior because does not sound like it should be. i am desperately trying to figure out if it something wrong with what I have done but I can't see anyway. ANybody tried this exact same thing and it works?

  9. #9
    Join Date
    Jan 2003
    Location
    Texas
    Posts
    10,413

    <a href="page.html" target="_parent">Break out of frames</a>


    [J]ona

  10. #10
    Join Date
    Mar 2003
    Posts
    26
    Not exactly what I am looking for. I have broken out of frames before but this one for some reason. I am trying to break out of frames so that I come out in the frame that is on the left. Problem it behaves as described above. SO you are in the right frame and I want set it up so the whole window becomes the left frame. Thanks for the help though, you have been helpful.

  11. #11
    Join Date
    Jan 2003
    Location
    Texas
    Posts
    10,413

    <body onload="if(self.location.href != top.location.href){top.location.href=self.location.href;}">


    [J]ona

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles