• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 261
  • Last Modified:

javascript pop-up window

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?
0
adventurer
Asked:
adventurer
  • 3
  • 3
1 Solution
 
slokCommented:
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 += "')";
 eval(code);
 }
0
 
adventurerAuthor Commented:
So, the "Always on Top" feature isn't available?
0
 
adventurerAuthor Commented:
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?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
slokCommented:
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?
0
 
adventurerAuthor Commented:
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.
0
 
slokCommented:
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
there...


0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now