Pop up issue

K

Kathleen Coyne

I am trying to find a script for a pop up that will pop up a new
window with a larger image with these requirements:

-if javascript is disabled, it must pop up a plain browser with the
image instead.

-close when clicked.

-close when another pop up is created.

-resize the pop up and image depending on screen resolution.

any ideas?

Thanks.
 
L

Lasse Reichstein Nielsen

I am trying to find a script for a pop up that will pop up a new
window with a larger image with these requirements:

-if javascript is disabled, it must pop up a plain browser with the
image instead.

Make it a link with a target:

<a href="imageWrapper.html" target="MyImageDisplay"

Then add an onclick handler for when Javascript is enabled:

onclick="myWinOpen(this)"> CLICK MED </a>

The myWindOpen function could be:

var myWinReference;
function myWinOpen(link) {
if (myWinReference) { myWinReference.close(); }
var imgSize = "medium";
var popupSize = "width=600,height=480";
if (screen.availHeight < 600) {
imgSize = "small";
popupSize = "width=400,height=300";
} else if (screen.availHeight > 1024) {
imgSize = "large";
popupSize = "width=800,height=600";
}
myWinReference = window.open("image-"+imgSize+".html",link.target,
popupSize+"resizable=yes");

}
-close when clicked.

The page that is loaded is an html file. It has an event handler:
-close when another pop up is created.

Handled above.
-resize the pop up and image depending on screen resolution.

Handled above, but you obviously will have to pick your own
delimiters.

/L
 
D

DU

Lasse said:
Make it a link with a target:

<a href="imageWrapper.html" target="MyImageDisplay"

Then add an onclick handler for when Javascript is enabled:

onclick="myWinOpen(this)"> CLICK MED </a>

You need to cancel the default action in the onclick event attribute if
js support is enabled. Otherwise, the link will be loaded in both windows.
The myWindOpen function could be:

var myWinReference;
function myWinOpen(link) {
if (myWinReference) { myWinReference.close(); }

This is not precise. The window could be closed and the pointer in
memory would still exist (e.g.: after viewing the 2nd enlarged image).
In such case, myWinReference.close(); would do nothing or create an error.

Also, trying to close the window as the first instruction does not make
a lot of sense. If the popup is just behind the opener (and this sort of
circumstances happens often to users) and if the link.href is the same,
then clicking again on the opener link will close and then recreate the
same popup: not an efficient way to manage user resources.
var imgSize = "medium";
var popupSize = "width=600,height=480";
if (screen.availHeight < 600) {
imgSize = "small";
popupSize = "width=400,height=300";
} else if (screen.availHeight > 1024) {
imgSize = "large";
popupSize = "width=800,height=600";
}
myWinReference = window.open("image-"+imgSize+".html",link.target,
popupSize+"resizable=yes");

The OP somewhat wants to create a functionality which is already
available and implemented in the UI, at the user's discretion in MSIE 6
and Mozilla browsers.
}




The page that is loaded is an html file. It has an event handler:



Handled above.

Closing a window by clicking in its content, on an image is not
intuitive, within normal, expectable user habits. I can understand a
large button (a real button, not a link) located at the bottom of a
document, closing a document in a window that needs to be scrolled
down... but clicking on an enlarged image to closed a window is def. not
consistent with user habits. Not recommendable IMO.
Handled above, but you obviously will have to pick your own
delimiters.

/L

Btw, the poster also multi-posted in alt.html newsgroup.

DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/
- Resources, help and tips for Netscape 7.x users and Composer
- Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x
http://www10.brinkster.com/doctorunclear/Netscape7/Netscape7Section.html
 
K

Kathleen Coyne

DU said:
Btw, the poster also multi-posted in alt.html newsgroup.

Yup. I did.

I posted there first. And then I realized that the chances of me
receiving any sort of valueable information would probably be almost
impossible.

I was right. It produced a little war about whether or not I should
have pop ups at all.

Then it dawned on me that those who wouldn't get into a tissy about
pop ups or using javascript would probably be those who are in a
javascript newsgroup :)

Thank you very much for your help.

I modified the javascript I got from:
http://www.stilleye.com/projects/dhtml/iPop/

I made it so the pop up would be a little smaller than the user's
available screen width and height, and then I made the image be as
wide or as tall as the pop up window. I then have to use two scripts,
one for tall images, and one for wide images.

hows that?

I actually don't know javascript at all <cower> pretty much all I do
is read what it's doing, try to understand what it's saying, and then
modify it to my needs. I haven't gotten to the point where I could
write it on my own, though.
 
R

rf

Kathleen Coyne said:
DU <[email protected]> wrote in message
Then it dawned on me that those who wouldn't get into a tissy about
pop ups or using javascript would probably be those who are in a
javascript newsgroup :)

Thank you very much for your help.

I modified the javascript I got from:
http://www.stilleye.com/projects/dhtml/iPop/

I made it so the pop up would be a little smaller than the user's
available screen width and height, and then I made the image be as
wide or as tall as the pop up window. I then have to use two scripts,
one for tall images, and one for wide images.

hows that?

That is incredibly bad. My browser window is currently about 700 wide by 800
high. A "little smaller than my available screen width and height" is going
to be a little smaller than 1600 by 1200. You have just covered up all of
the other windows on my screen!

Bloody arrogant if you ask me. What is wrong with letting me open the image
in my existing browser window?

Cheers
Richard.
 
D

Dr John Stockton

JRS: In article <[email protected]>,
That is incredibly bad. My browser window is currently about 700 wide by 800
high. A "little smaller than my available screen width and height" is going
to be a little smaller than 1600 by 1200. You have just covered up all of
the other windows on my screen!

Bloody arrogant if you ask me. What is wrong with letting me open the image
in my existing browser window?

If a picture needs to be viewed as a whole, there is something to be
said for opening it in a window which is large enough to contain it, but
no larger.

There is also something to be said for opening it in the current window
or a new one of similar or moderate size, so that the user deals with
the sizing.

Therefore, ISTM that the best thing is to provide two ways of opening
the picture, respectively "natural size" and whatever the other choice
is. Two links or buttons; or in some circumstances a checkbox or
radiobutton pair.

There is also something to be said for not opening a window bigger than
the screen.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top