Google Answers Logo
View Question
 
Q: Popup Windows on Mac Internet Explorer ( Answered 5 out of 5 stars,   0 Comments )
Question  
Subject: Popup Windows on Mac Internet Explorer
Category: Computers > Programming
Asked by: mindparasite-ga
List Price: $15.00
Posted: 23 Mar 2003 18:27 PST
Expires: 22 Apr 2003 19:27 PDT
Question ID: 180088
The following Javascript works on all tested versions of Netscape and
Internet Explorer for the PC.  However, the popup window flashes
repeatedly on Internet Explorer (5.1.4) for the Mac OS 10.  The popup
comes up but does not disappear on the IE 5.1.4 for Mac OS 9.  Any
corrections or modifications would be appreciated.

<SCRIPT LANGUAGE="Javascript">

var popup_window = null;

function popup(status,url)
{

        if(status != 0)
        {

        if(popup != null) popup.focus();

        else
                {
               
                var W = 290;
                var H = 425;
                var X = 1;
                var Y = 1;
                var winprefs =
"width="+W+",height="+H+",left="+X+",top="+Y+",screenX="+X+",screenY="+Y;
                var popup = open(url, "Popup", winprefs);
                popup_window = popup;

                }

        }
        else
        {

        if(popup_window != null) popup_window.close();
        }

}

</SCRIPT>

The function is called with the following:

onMouseover="popup(1,'some.htm')" onMouseout="popup(0)"


Thanks,
Roland
roland@edc.uri.edu

Request for Question Clarification by googleexpert-ga on 23 Mar 2003 21:36 PST
I tested the script(Mac OSX 10.0.4) and modified the following line:
if(popup_window != null) popup_window.close();


to 

if(popup_window != null) popup_window;

The popup window does not flash repeatedly in Internet Explorer but
instead stays open.

Can you tell me what the function is suppose to do?

Clarification of Question by mindparasite-ga on 24 Mar 2003 09:06 PST
The function needs to open a popup window when the pointer is over
(mouseover) a hyperlink and the popup window should close when the
pointer is no longer over the hyperlink (mouseout).  This needs to
work on all standard browsers as defined here:

http://welcome.colostate.edu/index.asp?url=info_browsers

I would prefer this to be a correction to the existing code and not
completely new code.

Thanks,
Roland
Answer  
Subject: Re: Popup Windows on Mac Internet Explorer
Answered By: wildeeo-ga on 25 Mar 2003 11:57 PST
Rated:5 out of 5 stars
 
Hi, mindparasite-ga. Thank you for your question.

The window appears to be 'flashing' in Mac IE 5 because of the way the
browser decides when the mouse has left the link (so executing the
'onMouseout' event).

In most Mac browsers (namely, Chimera, Safari, OmniWeb, and the Mac OS
9 version of Internet Explorer) when the window loses focus (which
will happen when the browser opens the popup), the browser will not
execute any more Javascript code until the window regains the focus
(i.e, they either click in it to bring it to the front, or they close
the popup so the window is now frontmost). This is the reason it did
not disappear when you tested it in the Mac OS 9 version of Internet
Explorer 5 - it will not execute the code to close the popup until the
window is frontmost again.

In the OS X version of Internet Explorer, the browser will continue to
handle and run Javascript events, even when the window is not at the
front. The problem is that when the popup opens, the browser assumes
that the cursor has moved out of the window that opened it (even if it
hasn't). This means that the browser thinks that the cursor is no
longer over the link, either. As it's still running Javascript in the
window, it will do whatever it's supposed to do when the mouse leaves
the link... which is to close the popup. The window will then jump to
the front again, and it will think the mouse has entered the window
and the link again, so it'll open the popup, notice the mouse has
'left' the window, close the popup... and so on. This is why it seems
to flash.

The bad news is that there is no way to make it do exactly what you
want in any of the Mac browsers. This is a limitation of the operating
system, and there's not much anyone, aside from the developers, can do
about it.

You could solve the flashing problem to some extent by not
automatically closing the popup if the user is running the OS X
version of Internet Explorer. This would at least allow your visitors
to read it. This can be done by changing the code to detect the
specific browser with the problem:

<SCRIPT LANGUAGE="Javascript"> 
 
var popup_window = null;
 
function popup(status,url) { 
 
    if(status != 0) { 
 
        if(popup != null) popup.focus(); 
        else { 
            var W = 290; 
            var H = 425; 
            var X = 1; 
            var Y = 1; 
            var winprefs =
"width="+W+",height="+H+",left="+X+",top="+Y+",screenX="+X+",screenY="+Y;
            var popup = open(url, "Popup", winprefs); 
                
            window.focus;
            
            popup_window = popup;
 
        } 
 
    } else { 
    
		if (!(navigator.appName == "Microsoft Internet Explorer" &&
parseInt(navigator.appVersion)>=4 && navigator.platform == "MacPPC"))
{

        	if(popup_window != null) popup_window.close(); 
        	
        }
        	
    } 
 
}
 
</SCRIPT>

Another solution would be to use completely different code to show the
information on the page.
http://www.dynamicdrive.com/dynamicindex5/index.html has several that
may be of use. If you simply wish to display some information when
they mouseover a link,
http://www.dynamicdrive.com/dynamicindex5/index.html may be useful -
and it works on all compliant browsers, IE for OS X included.

You may also find the following search of use:

'javascript window focus Mac IE'
(://www.google.com/search?q=javascript+window+focus+Mac+IE)

If you have any further queries about this, feel free to request a
clarification.

-- wildeeo
mindparasite-ga rated this answer:5 out of 5 stars
Thanks for helping out!  I think you have come up with a reasonable solution.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy