Click to See Complete Forum and Search --> : I tried using onclick to break out of frames and doesn't work.
webrunner
03-14-2003, 01:53 PM
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.
You can either use href="javascript:closeHelp()" or onClick="closeHelp()" but onClick="javascript:closeHelp()" is not acceptible.
webrunner
03-14-2003, 02:07 PM
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.
webrunner
07-02-2003, 05:09 PM
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.
<a href="default.htm" onClick="top.location.href=parent.real_choices.location.href; return false;">
[J]ona
webrunner
07-02-2003, 05:14 PM
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.
<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
webrunner
07-02-2003, 06:26 PM
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?
<a href="page.html" target="_parent">Break out of frames</a>
[J]ona
webrunner
07-02-2003, 06:42 PM
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.
<body onload="if(self.location.href != top.location.href){top.location.href=self.location.href;}">
[J]ona