Winopen function and browser behavior

M

Marty Morris

I used the following script to allow me to bring up a list of events
for a given year by simply hovering the mouse over the filename. As
follows --

<script Language="JavaScript">
function winopen1(){
msg1=open
("","WINDOW1","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=550,height=200");
msg1.location="1989H.htm"}
</Script>

Then....

<a href="1989H.htm" onMouseOver="winopen1();return true;"
onMouseOut="msg1.close();return true;">1989</a></font></td>

This is one example .... this is repeated about 20 times in the
program, one for each year of our history...

It works fine ... but not on all the browsers in our office. Most work
fine ... others (all IE) work fine on some dates; other dates, when
you hover, flash a blank page repeatedly until you move the mouse
away; almost as though it is looping ...

I notice that "about:blank" flashes briefly before the called page
comes up ... but that appears to be normal.... I have checked and
rechecked all coding, all brackets and semi-colons ... and it works
perfectly -- for me and for a few others.

Any ideas?

Thanks ...
 
G

Grant Wagner

Marty said:
I used the following script to allow me to bring up a list of events
for a given year by simply hovering the mouse over the filename. As
follows --

<script Language="JavaScript">
function winopen1(){
msg1=open
("","WINDOW1","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=550,height=200");
msg1.location="1989H.htm"}
</Script>

Then....

<a href="1989H.htm" onMouseOver="winopen1();return true;"
onMouseOut="msg1.close();return true;">1989</a></font></td>

This is one example .... this is repeated about 20 times in the
program, one for each year of our history...

It works fine ... but not on all the browsers in our office. Most work
fine ... others (all IE) work fine on some dates; other dates, when
you hover, flash a blank page repeatedly until you move the mouse
away; almost as though it is looping ...

I notice that "about:blank" flashes briefly before the called page
comes up ... but that appears to be normal.... I have checked and
rechecked all coding, all brackets and semi-colons ... and it works
perfectly -- for me and for a few others.

Any ideas?

Thanks ...

about:blank flashes because you're calling window.open() without a URL.

The problem is most likely that win1.location doesn't yet exist as an object when you try to access it. I'd bet you're getting a JavaScript
error something about Access Denied.

I don't understand why you open the window, then set it's location. I also don't understand why you'd hard-code all the individual URLs all
over the place, try this:

<script type="text/javascript">
function winOpen(theURL, theTarget) {
var windowRef = window.open(theURL, theTarget,
"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=550,height=200");
return windowRef;
}
</script>

<a href="1989H.htm" onMouseOver="window[this.href] = winOpen(this.href, this.target);return true;"
onMouseOut="if (window[this.href]) window[this.href].close();return true;">1989</a>

Now each link gets it's own popup reference so you know what window you're closing, you're specifying the location in one place (the HREF
attribute of the link) and you can use the same function for *every* link that does the same thing instead of having 20 functions that all do
the same thing.

--
| Grant Wagner <[email protected]>

* Client-side Javascript and Netscape 4 DOM Reference available at:
* http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/frames.html
* Internet Explorer DOM Reference available at:
* http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_entry.asp
* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 6/7 and Mozilla
* http://www.mozilla.org/docs/web-developer/upgrade_2.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,077
Messages
2,570,566
Members
47,202
Latest member
misc.

Latest Threads

Top