This function allows you to customize the display of images and other objects on a webpage. Because different images need to be dynamically loaded in some locations of the webpage, and their original size and proportion are unknown, if you set a fixed value (such as width = 50 height = 50), it may be displayed as distorted, therefore, a function is compiled for calling.
Picset. js File
Function SetObjSize (obj, w, h)
{
Var newW, newH, r;
R = w/h;
ImgObj = new Image ();
ImgObj. src = obj. href;
If (imgObj. width! = 0) & (imgObj. height! = 0 ))
{
If (imgObj. width> w | imgObj. height> h) | (imgObj. width <w & imgObj. height
{
If (imgObj. width)> r * (imgObj. height ))
{
Obj. height = imgObj. height * w/(imgObj. width );
Obj. width = w;
}
Else
{
Obj. width = imgObj. width * h/(imgObj. height );
Obj. height = h;
}
}
Else
{
Obj. height = "100% ";
Bj. width = "100% ";
}
}
Else
{
SetTimeout ("checkImg ('" + theObj + "', '" + w + "', '" + h + "')", 100 );
}
}
Webpage file example called
<%
Picfile = request ("picfile ")
%>
<Html>
<Head>
<Title> Untitled Document </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Script language = "javascript" src = "picset. js"> </script>
</Head>
<Body>
<Table align = "center" width = "100%" height = "100%">
<Tr>
<Td colspan = "2" align = "center" height = "100%" width = "100%">
</Td>
</Tr>
</Table>
</Body>
</Html>