javascript pop-up window

Posted on 1999-07-20
Medium Priority
Last Modified: 2013-11-28
I have a couple of thumbnail pictures and if I click the picture, I want to display the larger picture on a new pop-up window, but I don't want to create a new pop-up window everytime I click another pictures. I just want to create one pop-up window. Also I want this window ALWAYS on top (does javascript have this kind of feature??)
How do I do this?
Question by:adventurer
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
  • 3
  • 3

Accepted Solution

slok earned 200 total points
ID: 1852175
put the following in your picture link...
<a href="javascript:openAnyWindow('foo2.html',
                         'moreRemote', 'toolbar', 'resizable', 480, 200);">
                         open moreRemote<a>

NOTE : if u don't want the toolbar at the top of the browser, just
remove 'toolbar'....

this is the function...
function openAnyWindow(url, name) {
  var l = openAnyWindow.arguments.length;
  var w = "";
  var h = "";
  var features = "";

 for (i=2; i<l; i++) {
   var param = openAnyWindow.arguments[i];
   if ( (parseInt(param) == 0) ||
      (isNaN(parseInt(param))) ) {
   features += param + ',';
    } else {
    (w == "") ? w = "width=" + param + "," :
    h = "height=" + param;

 features += w + h;
  var code = "popupWin = window.open(url, name";
 if (l > 2) code += ", '" + features;
 code += "')";

Author Comment

ID: 1852176
So, the "Always on Top" feature isn't available?

Author Comment

ID: 1852177
Uhm... your function doesn't work perfectly. I want to change the size of the window dynamically. I tried to open 100x100 window at the first time and then 150x150 window at the second time, but your function failed to do this.

How can I add the code to close the existing window first, then open a new window again?
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!


Expert Comment

ID: 1852178
hi adventurer,

in the first block of codes that I post which looks like the one below..
<a href="javascript:openAnyWindow('foo2.html',
              'moreRemote', 'toolbar', 'resizable', 480, 200);">
              open moreRemote<a>

all u need to change for is the number 480 and 200.
they govern the width and height of the window.

when u say 'close' then open up again...
are u saying to have them open everytime u click close automatically?

Author Comment

ID: 1852179
what i want is if the window is opened, then closed it first, then open a new one with different size.
If I use the 'resizeable', it won't resize the window automatically if I click different picture with different size.

Expert Comment

ID: 1852180
it works on my test...

below is the codes that I use.
the JavaScript function remains the same...
 <a href="javascript:openAnyWindow('hunter.jpg',
                               'moreRemote', 'toolbar', 'resizable', 200, 200);">
                              open a 200x200</a> <br>
<a href="javascript:openAnyWindow('hunter.jpg',
            'moreRemote', 'toolbar', 'resizable', 400, 400);">
                             open a 400x400</a><br>

perhaps u can tell me the URL or address.. and I can take a look


Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Read on to get a few ideas on how to promote your next corporate event.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

719 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