我在 <head> </head>中定义了:
<script language="javascript" type="text/javascript">
var MaxWidth=70;
var MaxHeight=70;
var defaultPreSrc="img_df70.gif";
var maxbytes=49;
function DownImage(ImgD)
{
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0){
var rate = (MaxWidth/image.width < MaxHeight/image.height)?MaxWidth/image.width:MaxHeight/image.height;
if(rate <= 1){
ImgD.width = image.width*rate;
ImgD.height =image.height*rate;
}else{
ImgD.width = image.width;
ImgD.height =image.height;
}
}
}
</script> 然后在下面调用:
<body>
<form id="form1" runat="server">
<div>
<asp:Image ID="Image1" runat="server" OnLoad="DownImage(this)"/>
</div>
</form>
</body>
为什么总提示我:
错误“ASP.UpLoad_aspx”并不包含“DownImage”的定义
<script language="javascript" type="text/javascript">
var MaxWidth=70;
var MaxHeight=70;
var defaultPreSrc="img_df70.gif";
var maxbytes=49;
function DownImage(ImgD)
{
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0){
var rate = (MaxWidth/image.width < MaxHeight/image.height)?MaxWidth/image.width:MaxHeight/image.height;
if(rate <= 1){
ImgD.width = image.width*rate;
ImgD.height =image.height*rate;
}else{
ImgD.width = image.width;
ImgD.height =image.height;
}
}
}
</script> 然后在下面调用:
<body>
<form id="form1" runat="server">
<div>
<asp:Image ID="Image1" runat="server" OnLoad="DownImage(this)"/>
</div>
</form>
</body>
为什么总提示我:
错误“ASP.UpLoad_aspx”并不包含“DownImage”的定义
==>
<%@ Page Language="C#"%>
<script runat="server">
protected void Page_Load(object sender,EventArgs e)
{
Image1.Attributes.Add("onload", "DownImage(this)");
}
</script>
<script language="javascript" type="text/javascript">
var MaxWidth=70;
var MaxHeight=70;
var defaultPreSrc="img_df70.gif";
var maxbytes=49;
function DownImage(ImgD)
{
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0){
var rate = (MaxWidth/image.width < MaxHeight/image.height)?MaxWidth/image.width:MaxHeight/image.height;
if(rate <= 1){
ImgD.width = image.width*rate;
ImgD.height =image.height*rate;
}else{
ImgD.width = image.width;
ImgD.height =image.height;
}
}
}
</script>
<body>
<form id="form1" runat="server">
<div>
<asp:Image ID="Image1" runat="server"/>
</div>
</form>
</body>
var MaxWidth=70;
var MaxHeight=70;
var defaultPreSrc="img_df70.gif";
var maxbytes=49;
function DownImage(ImgD)
{
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0){
var rate = (MaxWidth/image.width < MaxHeight/image.height)?MaxWidth/image.width:MaxHeight/image.height;
if(rate <= 1){
ImgD.width = image.width*rate;
ImgD.height =image.height*rate;
}else{
ImgD.width = image.width;
ImgD.height =image.height;
}
}
}
function doload(){
doload = DownImage(document.getElementById("Image1"));
}
window.onload=function(){
document.getElementById("Image1").onload = doload;
}
</script>
<body>
<form id="form1" runat="server">
<div>
<asp:Image ID="Image1" runat="server" />
</div>
</form>
</body>