Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Anti-frame button works within site, outside gives "permission denied"

Status
Not open for further replies.

corpsinhere

Technical User
Feb 15, 2000
23
US
I posted earlier with a Q re. an anit-frame button. Now I have a popup window with a button that will break the frame within my site. But if the main window (as opposed to the navigation window) is displaying a page outside my site, the button does not work, and I get an error - Permission denied. Here is the code : <br><br>&lt;HTML&gt;<br>&lt;HEAD&gt;<br>&lt;TITLE&gt;Frame release&lt;/TITLE&gt;<br>&lt;SCRIPT LANGUAGE=&quot;JavaScript&quot;&gt;<br>&lt;!-- Hide the JavaScript from older browsers<br>function escape()<br>{<br> var win_a=window.opener;<br> var new_url=win_a.location;<br> document.writeln(new_url);<br> win_a.parent.location=new_url<br> close();<br>}<br><br>function bye()<br>{<br> close();<br>}<br> <br>// End hiding of script --&gt;<br>&lt;/SCRIPT&gt;<br>&lt;/HEAD&gt;<br><br>&lt;BODY&gt;<br>&lt;H3 ALIGN=&quot;center&quot;&gt;Want to leave the Leather Hyman frame?<br>&lt;FORM OnSubmit=&quot;return false;&quot;&gt;<br>&lt;INPUT TYPE=&quot;submit&quot; VALUE=&quot;Yes&quot; OnClick=&quot;escape();&quot;&gt;<br>&lt;INPUT TYPE=&quot;submit&quot; VALUE=&quot;No&quot; OnClick=&quot;bye();&quot;&gt;<br>&lt;/FORM&gt;<br>&lt;/H3&gt;<br>&lt;A HREF=&quot;#&quot; OnClick=&quot;escape();return false;&quot; RETURN=false&gt;Test&lt;/A&gt;<br><br>&lt;/BODY&gt;<br><br>&lt;/HTML&gt;
 
The writeln() function is unnecessary and is what is causing the error.&nbsp;&nbsp;What it's doing is that it's trying to write to the page after it's been loaded and you can't do that.&nbsp;&nbsp;It's really not necessary and doesn't really do anything for you.&nbsp;&nbsp;Also, notice that you are getting the location of only one frame above, which makes the assumption that someone is accessing your site from a place that used only two frame layers, but that won't always be the case.&nbsp;&nbsp;Use the top instead of parent.&nbsp;&nbsp;Also, close() (at least the way you used it) requires a signed script and does as much for you as writeln().&nbsp;&nbsp;The proper way to use closee() is window.close()<br>My code:<br><FONT FACE=monospace><br>...<br>function escape()<br>{<br>top.location.href=this.window.location.href<br>}<br>...<br></font> <p>REH<br><a href=mailto:hawkdogg@crosswinds.net>hawkdogg@crosswinds.net</a><br><a href= by Linux</a><br>Learn Linux and Leave out the Windows :)
 
at hem. ndogg is right. but.<br>don't use the line 'function escape()' line<br>the escape() function is predefined in javascript.<br>when you run a string through it, it does things like replace a space with a %20, etc.<br><br>try using another name.<br> <p>theEclipse<br><a href=mailto:eclipse_web@hotmail.com>eclipse_web@hotmail.com</a><br><a href=robacarp.webjump.com>robacarp.webjump.com</a><br>**-Trying to build a documentation of a Javascript DOM, crossbrowser, of course. E-mail me if you know of any little known events and/or methods, etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top