Newsgroup: it.comp.lang.javascript
Titolo: Picturesize using JavaScript

Hi!
I recently posted a message regarding the very same subject, but didn't get
any answers. Something tells me that it might be impossible to do what I
want, but since it's very important for me I just have to send this question
again. What I want to do is include the filename of a JPG in a functioncall.
Example: popup('picture.jpg');
And then let the function popup() determine the width and height of that
picture so I can open a new window the same size of the picture. Is it
possible to do this? If not in Javascript, can I do it in Java then?
Please help me, I will be very grateful...
I appologize for sending this to groups using other languages, but I'm
desperate... :-)
/Rodin

with javascript it isn't possible
but with asp you could do it
there's a component at 
www.serverobjects.com
that gets the height and width of an image file for you
Kevin
M.Rodin <ro...@writeme.com.spamskydd> wrote in message
news:aRUP4.2535$wYl.19...@newsb.telia.net...


 possible to do this? If not in Javascript, can I do it in Java then?
var newWindow=window.open
("
http://www.yourdomain.com/blankpage.html
","","resizable=no","scrolling=no"
,"status=no","width=500", "height=1000")
newWindow.document.writeln('<img src="
http://www.yourdomain.com/picture.jpg
"
width=500 height=1000></img>')
--Thank You
Robert T. Hercules (Robherc)
rob...@freewwweb.com
TipMaster Winner at 
www.Tek-Tips.com

 >





 Does someone know about the equivalents for Netscape?
hmmm...maybe you could get the onLoad action to let you know when it's
finished loading (instead of readyState). And as far as the image()
properties (width or height), I believe, on second thought, that you would
find it about 15x easier to do what you are wanting if you place each image
in an HTML document of its own (with just a title, a body tag, and an img
tag) and assigned each image a height, width, etc...or made a .js library
that you load in this page that has the data for each image. Let me know
what you think & I'll see if I can't be of any more assistance :-)
--Thank You
Robert T. Hercules (Robherc)
rob...@freewwweb.com
Annual Tip Master winner at 
www.Tek-Tips.com

 wrote in message
news:8f5m04$1gs$2...@news.smartworld.net...



Rodin:
I use the following code with success in both IE and Netscape. "isNS"
and "isIE" are set elsewhere in a browser sniffer routine. LoadGraph()
is called in this fashion:
<A CLASS="Graph" HREF="#" onClick="LoadGraph('CSCO.gif');return
false;">Cisco Systems</A>
You might want to tweak gBorder a bit. I stopped when I arrived at a
value that seems to work. One thing I did notice is that if you use new
Image() with arguments IE will not return the true size; so I omit the
width,size arguments.
if (isNS)
  var gBorder = 20; // Minimum image border to avoid scrollbars in
Netscape
else
  var gBorder = 55; // Minimum image border to avoid scrollbars in IE
function LoadGraph(GraphURL)
{
  gURL = "./charts/" + GraphURL;
  var Graph = new Image();
  var gWidth = 200;		// A default width and height
  var gHeight = 160;
  Graph.src = gURL;		// Fetch the graph
  Graph.onload = GraphResize;	// Resize to true dimensions
  winFeatures =
"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="
+ gWidth + ",height=" + gHeight + ",screenX=0,screenY=40,top=40,left=0"
if (gWin && !gWin.closed)
  gwin.location.href=gURL;
else
  gWin = window.open(gURL,"GraphWin",winFeatures);
  gWin.focus();	 //	Force to top
}
function GraphResize(ole)
{
  gWidth = this.width + gBorder;
  gHeight = this.height + gBorder;
//	alert ("Width:" + gWidth + " x Height:" + gHeight);
  gWin.resizeTo(gWidth,gHeight)
}
Good luck. I hope this addresses your problem or at least points you in
a fruitful direction.
--
"Nothing is so disastrous to liberty as a successful revolution;
the greatest tragedy that can befall an ideal is its fulfillment."
(Will Durant, 1885-1981)