View Full Version : Please help..This is the last piece of code to get working

07-02-2005, 01:46 PM
Thanks to Gary Newell for the help with the popups...I have it working .."almost"...if i call the popup from an image it has focus and is on top..if I click another image the new url loads and focus stays on top..this is all perfect so far but 1 problem left....if i close the popup after calling it from one of the images and then click another image to popup the window I get an Script error
..says line 17
charactor 4
unspecified error
code 0
so it looks to see if a window is open and if so load new url and give focus. but if you pop one up then close it yourself and click another image it errors. If you refresh the page it works ok again unless you close the popup window.
Here is a link to the page

http://www.lhfcorp.com/wood/rightlaminate.html when you get there click an image and popup will work...click another image and popup will load new url an get focus...now close the popup and try clicking any image again..no popup and error occurs.

...can anyone help...this is thre last piece of the site to get working..

07-02-2005, 05:11 PM
First of all, things are a bit ambiguous. You have both a window name and a variable name of 'window1'. Another thing, you seem to not realize that the browser is perfectly capable of checking to see if a window named window1 already exists and, if so, replacing its contents with the new url and, if not, opening it first. The browser also has no problem in giving focus to a window it has just opened. One more thing, the language attribute for the script tag is deprecated, don't use it. With all this in mind, your script can be simplified to:
<script type="text/javascript">
function showit(txt)
window1 = window.open(txt,"window1","width=750,height=400,left=115,top=130,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=yes");
</script>Also, the links like this one:
<a href=# onclick="showit('http://www.columbiaflooring.com')">should probably be:
<a href="http://www.columbiaflooring.com" onclick="showit(this.href);return false;">to prevent unwanted windows from opening and/or page reloads from happening. And to give non javascript enabled browsers something to see.

07-02-2005, 05:29 PM
One more thing, unless this page is normally in a frameset that includes a frame named "right", get rid of this:
<base target="right">or, considereing only non javascript enabled browsers will use it (even in a frameset), change it to:
<base target="_blank">