Forum Moderators: open

Message Too Old, No Replies

dropdown menu

beginner

         

hugo

4:58 pm on Sep 18, 2004 (gmt 0)

10+ Year Member



hello, im am using a dropdown menu on my site. I picked the code from a pull down menu generator. each option links to a different image and it opens a new window when selected.
The problem is that i cant control the size of the window that opens, and i would like to fit it to the size of the image(or at least aproximately).
thanks for reading
hugo

adni18

9:28 pm on Sep 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ah. Easy one. But my script may vary from the one you are using:

<script language=javascript>
function openImg(JSobject) {
var selected=JSobject.options[JSobject.selectedIndex];
if(selected.value!="*"){
window.open(selected.value,'image','width='+selected.dimX+',height='+selected.dimY)
}
}
</script>
<select onChange="openImg(this)">
<option selected value="*">Pick An Image</option>
<option dimX="300" dimY="200" value="image1.jpg">Image 1</option>
<option dimX="545" dimY="692" value="image2.jpg">Image 2</option>
</select>

hugo

10:47 pm on Sep 23, 2004 (gmt 0)

10+ Year Member



works great adni thanks

adni18

4:15 pm on Sep 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



any time!

dcrombie

11:32 am on Sep 26, 2004 (gmt 0)



I'm not sure that you can rely on that method. It seems to work in Safari(Mac) and MSIE(Mac) but not in Opera or any of the Mozilla browsers (incl. Camino and Firefox). It's also not something I've (ever) seen documented.

I suspect a design flaw in Explorer lets you create arbitrary attributes in HTML. Not sure what Safari's excuse is (Dave? [weblogs.mozillazine.org]).

adni18

6:28 pm on Sep 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, then, you can always do it like this:

<script language=javascript>
function openImg(JSobject) {
var selected=JSobject.options[JSobject.selectedIndex];
if(selected.value!="*"){
imgW=selected.value.split(";")[1];
imgH=selected.value.split(";")[2];
window.open(selected.value,'image','width='+imgW+',height='+imgH)
}
}
</script>
<select onChange="openImg(this)">
<option selected value="*">Pick An Image</option>
<option value="image1.jpg;300;200">Image 1</option>
<option value="image2.jpg;545;692">Image 2</option>
</select>