Click to See Complete Forum and Search --> : java script window code, how?
Hi everybody!
I need a function in java script that I give it an address of some image and it open a pop-up with the image size(auto size).
Does anybody knows how to do it?
Thank you
zeke676
07-19-2005, 06:11 PM
how about this?
function autosize(image) {
var i = new Image();
i.src = image;
var x = i.width;
var y = i.height;
var z = "scrollbars=no,width=" + (x+20) + ",height=" + (y+20);
window.open(image,"image",z);
}
bwkaz
07-19-2005, 07:17 PM
Popups are EVIL!
;)
It code didn't works, it stay a size of 20px. What's happening?
psi42
07-19-2005, 09:48 PM
Why, why, WHY would you ever want to do this? NO ONE browsing your site wants to see a new window open in front of them... ;)
hey folks!
this script is to a gallery of imagens, and each has a size, because this I need a autosize window.
Can somebody help-me?
knute
07-19-2005, 10:00 PM
Hi everybody!
I need a function in java script that I give it an address of some image and it open a pop-up with the image size(auto size).
Does anybody knows how to do it?
Thank you
Why do you want to use javascript when all you need to do is to use the target option of img?
http://www.w3schools.com/html/tryit.asp?filename=tryhtml_link_target
Why do you want to use javascript when all you need to do is to use the target option of img?
http://www.w3schools.com/html/tryit.asp?filename=tryhtml_link_target
But my client want a good visual for the page, because this I want to use javascript...
how can I do it with no javascript? Can you tell-me?
thanks
knute
07-19-2005, 10:31 PM
I'd add a class in the img tag, that holds the css commands to configure the new window.
I don't like popups, so it's not something that I've explored to much. However, you can get some nice effects with z-axis and mouseovers. CSS is fun to play with. There are so many things that you can do with it. (One of my favorites is making menu's with it. :) )
I'd add a class in the img tag, that holds the css commands to configure the new window.
I don't like popups, so it's not something that I've explored to much. However, you can get some nice effects with z-axis and mouseovers. CSS is fun to play with. There are so many things that you can do with it. (One of my favorites is making menu's with it. :) )
use CSS is a good idea, but my client want a pop-up I can't change his opinion.. :(
But I'll try to find somethink like pop-up in CSS, thanks!
but some one have more opinios? if possible in java script :D
zeke676
07-19-2005, 10:52 PM
It code didn't works, it stay a size of 20px. What's happening?
you have to pass the image to the function.
you have to pass the image to the function.
I put to call the image but didn't works...
I try with IE and Mozilla Firefox
Do you know why it's happening?
knute
07-19-2005, 11:25 PM
I'm not sure, but isn't the actual name of the image supposed to be somewhere in your script?
Like maybe in the call to open the window?
I'm not sure, but isn't the actual name of the image supposed to be somewhere in your script?
Like maybe in the call to open the window?
I'm calling the image with this code:
<img src="<?php print $row['mod']['gal1']; ?>" border="0" onClick="autosize('gestor/img_galeria.php?img_url=<?php print $row['mod']['gal1']; ?>')" width="89" height="56">
it call:
onClick="autosize('gestor/img_galeria.php?img_url=<?php print $row['mod']['gal1']; ?>')"
and the javascript is:
function autosize(image) {
var i = new Image();
i.src = image;
var x = i.width;
var y = i.height;
var z = "scrollbars=yes,width=" + (x+20) + ",height=" + (y+20);
window.open(image,"Galeria",z);
}
Any erros?
zeke676
07-20-2005, 12:28 AM
<script language="JavaScript" type="text/javascript">
function autosize(image){
var i = new Image();
i.src = image;
var x = i.width;
var y = i.height;
window.open(image,"GALLERY","width=" + x + ",height="+y);
}
</script>
</head>
<body>
<a href="#" onclick="autosize('image1.jpg')"><img src="image1.jpg"></a>
</body>
it works fine for me running firefox
it works fine for me running firefox
It opened a window into all screen(1024x768), happened in FireFox and IE...
What can I do now?
thanks
bwkaz
07-20-2005, 06:44 PM
Because popups are EVIL (see my post above), Firefox has a bunch of options to prevent javascript from doing stuff. Bringing up windows is one. Changing the statusbar is another. Removing the statusbar is a third. Resizing windows is a fourth.
The last one may be what's causing a problem in your FF test.
IE doesn't do this that I know of, but maybe you should still tell your client that he's an idiot for wanting it to be a popup. (j/k -- but I'd express my displeasure in some way if I were you.)
Yes... they´re...
I have pop-up but if a client tell-me to do that I have to do.. :mad:
well, thank you to evebody that help-me!
I will use a simple pop-up...
Hello again!
I want again a code that open a window with the images size, the last script posted here didn't work... :(
Can somebody help-me?
Thank you!!