window.open

Hi,
I am trying to open a new window and it works fine in Microsoft Front page but it doesn't work when i open the page on the local server.
I do have antivirus loaded on my machine.  I tried disabling the script blocking but it still doesn't work.

this is the code that i am using

<script language ="Javascript">
//TO OPEN A POPUP WINDOW IN THE CENTER OF THE SCREEN
function popWin(file, width, height)
{
        // Define Window width and height right here so that it can easily be modified.
    var winWidth = width;
    var winHeight = height;
     
     // Midx and Midy will be used to center the window.
     var midx = (screen.width/2) - (winWidth/2);
     var midy = (screen.height/2) - (winHeight/2)
     
     // Set up the Propeties String
    var props = "'scrollbars=yes,resizable=yes," +"height=" + winHeight + ",width=" + winWidth + ",screenX=" + midx + ",screenY=" + midy + ",top=" + midy + ",left=" + midx +"'";    

       if(!window.theWin){
      theWin = window.open(file, "SubWin", "");
   }else{
     if(theWin.closed)
       theWin = window.open(file, "SubWin", "");
     else{
       theWin.close()
       theWin = window.open(file, "SubWin", "");
     }
   }
  }

popWin('http://localhost/subscribe.htm',400,450);


</script>
maitrishahAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lil_puffballCommented:
Does your web provider automatically insert that pop-up blocker srcript? If so that's probably the problem.
0
jaysolomonCommented:
try this on your loacl server

<html>
<head>
<title>open New Window</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
<!--
function openWin(theURL,winName,features) {
  window.open(theURL,winName,features);
}
//-->
</script>
</head>

<body bgcolor="#FFFFFF" text="#000000">
<p><a href="#" onClick="openWin('http://Yahoo.com','winYahoo','width=300,height=400')">Yahoo!</a></p>
<p><a href="#" onClick="openWin('http://cnn.com','winCNN','width=800,height=600')">Cnn</a></p>
<p><a href="#" onClick="openWin('http://microsoft.com','winMicrosoft','width=400,height=500')">Microsoft</a></p>
</body>
</html>
0
maitrishahAuthor Commented:
Hey,
how come that worked and my function didn't worked.
What did i do wrong ?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

maitrishahAuthor Commented:
Hey,

But your function doesn't work if i call it like this

<body bgcolor="#FFFFFF" text="#000000" onload ="openWin('http://Yahoo.com','winYahoo','width=300,height=400')" >
0
maitrishahAuthor Commented:
Hey,

But your function doesn't work if i call it like this

<body bgcolor="#FFFFFF" text="#000000" onload ="openWin('http://Yahoo.com','winYahoo','width=300,height=400')" >
0
maitrishahAuthor Commented:
Hey,

But your function doesn't work if i call it like this

<body bgcolor="#FFFFFF" text="#000000" onload ="openWin('http://Yahoo.com','winYahoo','width=300,height=400')" >
0
jaysolomonCommented:
It worked for me:
Try this

<html>
<head>
<title>open New Window</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
<!--
function openWin(theURL,winName,features) {
  window.open(theURL,winName,features);
}
//-->
</script>
</head>

<body onLoad="openWin('http://Yahoo.com','winYahoo','width=300,height=400')">
<p><a href="#" onClick="openWin('http://Yahoo.com','winYahoo','width=300,height=400')">Yahoo!</a></p>
<p><a href="#" onClick="openWin('http://cnn.com','winCNN','width=800,height=600')">Cnn</a></p>
<p><a href="#" onClick="openWin('http://microsoft.com','winMicrosoft','width=400,height=500')">Microsoft</a></p>
</body>
</html>
0
maitrishahAuthor Commented:
No, it didn't work for me. It didn't show any pop up.
0
jaysolomonCommented:
copy/paste my last code and try it. i have tested it in NS7 and ie6 it works like a charm

If it doesn't work for you then you have some sort of pop up blocker on your system
0
maitrishahAuthor Commented:
I tried copy/paste your code but it didn't work.  Is there any settings that i can check on IIS or IE or anitvirus.
How can i find out if i do have a pop up blocker?  Even if i do have a pop up blocker then how come i can view a pop-up if i click on a link and can't view in an onload event.
0
whammyCommented:
If you can view the popup when you click on a link, but can't view it onload, then I'd think you definitely have a program that's running in the background that's causing you problems.

What OS (Operating System) are you using?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
whammyCommented:
If it's Win2000 or XP, you should be able to hit CTRL+ALT+DEL and see what programs are running.

You might want to go uninstall whatever popup blocker you've got going (a good start is going into your Add/Remove Programs section in Control Panel, and getting rid of things you obviously didn't install, as long as you're sure that it is something you don't need).

After that, I would research the startup menu (a google search will provide you with a plethora of good (and bad) links). But you need to look into msconfig, etc. so you can take stuff out of your startup menu that isn't necessary, and that you didn't install...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.