首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

JS方法里调用另一个JS方法!解决办法

2012-05-27 
JS方法里调用另一个JS方法!请问一下怎么在一个JS方法里调用另外一个JS方法,如JS1script languagejavasc

JS方法里调用另一个JS方法!
请问一下怎么在一个JS方法里调用另外一个JS方法,如JS1 
<script language="javascript" type="text/javascript">
function showBig<%#Eval("Id") %>()
{
  var bigsrc='<%#Eval("ProAdress") %>';
  var bigImg = document.createElement("IMG");
  bigImg.src=bigsrc;
  bigImg.onload="此处要怎么写?"
  var digDiv = document.getElementById("bigDIV");
  digDiv.innerHTML="";
  var Title = document.getElementById('<%#Eval("id") %>').alt;
  A.innerText = Title;
  digDiv.appendChild(bigImg);
}
</script>


JS2
<script language="javascript" type="text/javascript">
  function DrawImage(ImgD,iwidth,iheight){  
  //参数(图片,允许的宽度,允许的高度)  
  var image=new Image();  
  image.src=ImgD.src;  
  if(image.width>0 && image.height>0){  
  if(image.width/image.height>= iwidth/iheight){  
  if(image.width>iwidth){  
  ImgD.width=iwidth;  
  ImgD.height=(image.height*iwidth)/image.width;  
  }else{  
  ImgD.width=image.width;  
  ImgD.height=image.height;  
  }  
  }else{  
  if(image.height>iheight){  
  ImgD.height=iheight;  
  ImgD.width=(image.width*iheight)/image.height;  
  }else{  
  ImgD.width=image.width;  
  ImgD.height=image.height;  
  }  
  }  
  }  
}  

</script>

用JS1调用JS2 ,在JS1里面定义img 的onload事件?

[解决办法]
首先,必须满足两个情况:1.js1和js2必须是父子窗口关系
2.js1和js2隶属于同1个html

第一种情况,如果js1是子窗口 调用的话用parent.方法

第二种情况,直接调用

热点排行