PDA

View Full Version : Pop-Up windows in IE7



tr3x86
02-27-2008, 05:43 PM
Hello All,

First time poster, long time viewer... need a little help...

I'm trying to generate a small pop-up window to show some copy.

I found this code from a generator on this site...


<script language="javascript" type="text/javascript">
<!--
/****************************************************
Author: Eric King
Url: http://redrival.com/eak/index.shtml
This script is free to use as long as this info is left in
Featured on Dynamic Drive script library (http://www.dynamicdrive.com)
****************************************************/
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,re sizable=no';
win=window.open(mypage,myname,settings);}
// -->
</script>

The pop-up works perfectly with the size requirements I set in Firefox and friends, but once I test it in Internet Explorer 7, it pretty much ignores all attributes and opens the pop-up window in _self.

I just want it to function in all platforms...

Thanks for your time!

~Tyler :)

uppercanuck
03-04-2008, 01:18 PM
Hi, Tyler,

I'd suggest not using traditional popups for many reasons, one being that browser popup blockers often interfere with these kinds of scripts. The other is that it's difficult to get the same results across all browsers, especially when it comes to showing/hiding window elements within that popup.

Instead, you could use one of the modal alerts found in the Ajax section of Dynamic Drive, or go to www.ajaxrain.com and do a search for "modal" or "alert" and you'll find a variety of scripts to choose from.

Good luck!

UC

jscheuer1
03-04-2008, 01:39 PM
Right. Another reason not to use traditional pop ups is, even when they are allowed, browsers may be configured to do something else with them, other than what is expected (like launch in the same window, or launch in a new tab). That appears to be the case here, though the value you are passing to it as myname may simply be invalid from IE 7's point of view. This is a fairly good DD script for pseudo pop ups:

http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/index.htm