Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org

Feedback: irt.org FAQ Knowledge Base Q845

Feedback on: irt.org FAQ Knowledge Base Q845

Sent by Jeff Barnes on November 24, 1999 at 09:08:02: - feedback #620

Worth:
Worth reading

Length:
Too short

Technical:
Just right

Comments:
Problem: how do I error trap in IE if the main window is closed? As it is now, I get an "unspecified error" on opener.location.href.

This is a fairly serious bug in the script.


Sent by Adam Edell on July 20, 2000 at 13:31:47: - feedback #1512

Worth:
Worth reading

Comments:
Hi!

This was exactly my question, too! What in the world is the:
window.onerror = supressError for??? Is this essential??

I love your site and your solutions... by the way... now that I've flattered you... you seem to have provided a script that does not take advantage of other useful tips you give elsewhere... I'd like you to consider this solution which combines the best of everything I think: compatiblity with the widest range of browsers. I'd love your opinion because I haven't been able to test it in IE3 or NS2,3 yet but it should degrade nicely... It works in IE5 and NS4.x, and functions well even if JavaScript is disabled...

The question was "Q845: From the main window I open a smaller child window, in this child window, if a user selects a link, I want to load the new page in the main browser window and close the child window. How do I do this?"

Here are the scripts:

In the main window:

<script language=JavaScript>
</script>

<a href="popup.html" target="mywindow" onClick="openawindow();return false">click here</a>

Notice that I use regular HTML links and override them with onClick... then I use return false for IE5 to not link to the HTML link... this is the MOST compatible I can think of...

Here is the script and HTML for the popup window (all links are regular HTML!)...

<SCRIPT LANGUAGE="JavaScript">
if (document.images)
opener.name = "mainwindow"
function closewindow(){
if (document.images){
setTimeout('window.close()',2000);
if (!opener.closed)
opener.focus();
}
return true
}
</SCRIPT>

<a href="http://www.yahoo.com" target="mainwindow" onClick="return closewindow()">go to yahoo in main window></a>

Notice that I set this script to be JavaScript but limit all functionality to those where document.images is true. I think this is the best idea for graceful degradation... Earlier browsers should simply ignore the onClick and open a new window nicely... the only problem is with IE3 which I'm not sure how it will react... I'm gonna dig up a copy... Also, I add the timeout for Netscape compatiblity... (IE doesn't need any timeout...) Also, I use the onClick="return closewindow()" even though it does not seem to need a "return" to work nicely...

The only remaining question still remains, what's the:

window.onerror = supressError for???

Love your site!



©2018 Martin Webb