...

View Full Version : open new window



alaios
08-24-2002, 09:24 PM
i want to open a new window in the picture dimensions
Ia m using the folowing code to resize the window
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-7">
<script language="JavaScript">
var number=document.URL
var number=number.split('/');
var mikos=number.length;
var eikona=number[mikos-1]; //1.htm
var mikos=eikona.length;
var eikona=eikona.substr(0,mikos-4);

</script>
</head>

<body bgcolor="#FFFFFF" text="#000000">
<div align="center"> <a href="javascript:window.close();"><img src="" name="pic1" border="0" alt=" " height="300">
</a>
<script language="JavaScript">

document.images['pic1'].src=eikona+".jpg";
setTimeout("resize();",500);
function resize()
{
var width=document.images['pic1'].width;
var height=document.images['pic1'].height;+
window.resizeTo(width,height);
if (window.screen) {
self.moveTo((screen.availWidth-width)/2,(screen.availHeight-height)/2);
}
}
</script>
</div>
</body>
</html>

the main problem is that when the window opens is very small because (<img src="" name="pic1" border="0" alt=" " height="300"> ) and the bigger picture is being loaded in the small window.What i must do.. I was thinging to use the onload to resample the wind?ow to the picture! plz help me

justame
08-25-2002, 01:46 AM
ala...
one of the other just a forum members...reyn...just a posted this before...



Well, that's just a matter of knowing the image's dimensions beforehand, and using that as the parameters for opening a window of the specified size.
This simple reusable function can be called by any link that passes it the image filename, and the height and width of the image, then pops out the image in a new window of approximately that size.

Somewhere in the HEAD, insert:

<script language="JavaScript">
<!--
function show(pic,h,w){
var size="height="+h+",width="+w;
var show=open(pic,'',size)}
//-->
</script>

And for example, you want to show an image 300 pixels high x 300 pixels wide. Then just call the function and pass it the correct parameters, in this order: filename.jpg, height, and width.

<a href="javascript:show('mypic.jpg',320,320)">Show me</a>

The added 20 is optional to offset for the default top and left margins of browsers.


just a goodluck :O)))



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum