?
Solved

window.open

Posted on 2003-03-14
12
Medium Priority
?
596 Views
Last Modified: 2012-05-04
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>
0
Comment
Question by:maitrishah
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 2
  • +1
12 Comments
 
LVL 12

Expert Comment

by:lil_puffball
ID: 8139154
Does your web provider automatically insert that pop-up blocker srcript? If so that's probably the problem.
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 8139272
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
 

Author Comment

by:maitrishah
ID: 8139388
Hey,
how come that worked and my function didn't worked.
What did i do wrong ?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:maitrishah
ID: 8139494
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
 

Author Comment

by:maitrishah
ID: 8139502
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
 

Author Comment

by:maitrishah
ID: 8139521
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
 
LVL 16

Expert Comment

by:jaysolomon
ID: 8139542
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
 

Author Comment

by:maitrishah
ID: 8139560
No, it didn't work for me. It didn't show any pop up.
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 8139602
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
 

Author Comment

by:maitrishah
ID: 8139627
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
 
LVL 4

Accepted Solution

by:
whammy earned 75 total points
ID: 8140650
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
 
LVL 4

Expert Comment

by:whammy
ID: 8140667
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question