PDA

View Full Version : Need some help with popup script please.



Cheng
09-27-2007, 07:17 AM
1) Script Title: Popup Window Generator

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex8/popwin.htm

3) Describe problem:

Hi.

Can someone please help me out with this popup script.
Why I can"t test the script (below) offline, or is it normal that it works only online?


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Popup</title>
<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>
</head>

<body>
<a href="http://www.google.com" onclick="NewWindow(this.href,'mywin','400','300','no','center');return false" onfocus="this.blur()">YourLinkText</a>
</body>
</html>

Thanks,
Cheng

codeexploiter
09-27-2007, 08:34 AM
The script you've provided working correctly for me in both MS IE and Mozilla FF without any problem. Just open the page in your browser and click the link and that will open a popup window.

If you are getting any error or messages please post that things here or mention a URL of the page in your posting.

Cheng
09-27-2007, 11:31 AM
Thanks for the quick reply.
The script was working fine but I couldn't test it offline which is now working again, don"t ask me why that is.
I just thought that I was doing something wrong with the script.

Thanks again,