showimg.js
上传用户:yatiankong
上传日期:2014-05-16
资源大小:5604k
文件大小:3k
源码类别:

Applet

开发平台:

Java

  1. var showFlag = false;
  2. var oldelm1;
  3. var timeElm ;
  4. function showBigImg(image, id, event)
  5. {
  6. if(navigator.userAgent.indexOf("Firefox")>0) //是Firefox浏览器
  7. {
  8. showBigImgFF(image, id, event);
  9. }
  10. else   //包括微软在内的使用
  11. {
  12. showBigImgMS(image, id);
  13. }
  14.     //if(isFirefox=navigator.userAgent.indexOf("Firefox")>0)return 2;
  15. }
  16. function showBigImgMS(image, id)
  17. {
  18. var elm1 = window.event.srcElement;
  19. showFlag = true;
  20. var beginShow = function() {BeginShow(elm1, image, id);} 
  21. //alert(1);
  22. timeElm = window.setTimeout(beginShow, 550);
  23. }
  24. function BeginShow(elm1, image, id)
  25. {
  26. //var elm2 = window.event.srcElement;
  27. if( showFlag)
  28. {
  29. ShowInfo(elm1, image, id);
  30. }
  31. }
  32. function ShowInfo(elm1, image, id)
  33. {
  34. //<img src="images/head_01.jpg"  />
  35. if(elm1 !=oldelm1)
  36. {
  37. RemoveElm('imgpanel');
  38. var str = '<div style="position:absolute; z-index:10 ;" id=imgpanel>';
  39.  str += '<div style="position:absolute;  border:#666666 1px solid; z-index:10 ;left:-4px;top:-10px  ">';
  40. str +='<div style=" border:#E8E8E8 5px solid;  padding:15px ; background-color:#FFFFFF  ">';
  41. str +='<div style=" border:#B6B6B6 2px solid;  " id=imgArea>';
  42. str +='<img src="product_image/' + image + '" id="num_' + id + '" /></div></div>';
  43. str +='<img src="js/arra.gif"  style="position:absolute; z-index:2 ; left:-10px;top:12px"   />';
  44. str +='</div></div>';
  45. var parentElm = elm1.parentNode;
  46. if(parentElm)
  47. {
  48. parentElm.innerHTML+=str;
  49. }
  50. var a = new Image();
  51. a.onload =  function(){ var elm = document.getElementById("num_"+id); if(elm){elm.src = a.src}}
  52. a.src = "product_image/" + image;
  53. oldelm1 = elm1;
  54. }
  55. else
  56. {
  57. }
  58. }
  59. function RemoveElm(elmId)
  60. {
  61.     try
  62.     {
  63.         var elm = document.getElementById(elmId);
  64. if(elm)elm.parentNode.removeChild(elm);
  65.     }
  66. catch(e)
  67. {
  68.         //alert('RemoveEml' + e.description);
  69. }
  70.     
  71. }
  72. function mouseout(image)
  73. {
  74.     try
  75.     {
  76.     RemoveElm('imgpanel');
  77.     if(timeElm)
  78.     {
  79.             window.clearTimeout(timeElm);
  80.         }
  81.     }
  82.      catch(e)
  83. {
  84.         //alert('RemoveEml' + e.description);
  85. }
  86. }
  87. //-----------FF浏览器调用
  88. function showBigImgFF(image, id, event)
  89. {
  90. var elm1 = event.target;
  91. showFlag = true;
  92. var beginShow = function() {BeginShowFF(elm1, image, id);} 
  93. //alert(1);
  94. timeElm = window.setTimeout(beginShow, 550);
  95. }
  96. function BeginShowFF(elm1, image, id)
  97. {
  98. //var elm2 = window.event.srcElement;
  99. if( showFlag)
  100. {
  101. ShowInfoFF(elm1, image, id);
  102. }
  103. }
  104. function ShowInfoFF(elm1, image, id)
  105. {
  106. //<img src="images/head_01.jpg"  />
  107. if(elm1 !=oldelm1)
  108. {
  109. RemoveElm('imgpanel');
  110. var str = '<div style="position:absolute; z-index:10 ;" id=imgpanel>';
  111. str += '<div style="position:absolute;  border:#666666 1px solid; z-index:10 ;left:80px;top:-70px  ">';
  112. str +='<div style=" border:#E8E8E8 5px solid;  padding:15px ; background-color:#FFFFFF  ">';
  113. str +='<div style=" border:#B6B6B6 2px solid;  " id=imgArea>';
  114. str +='<img src="product_image/' + image + '" id="num_' + id + '" border="0" /></div></div>';
  115. str +='<img src="js/arra.gif"  style="position:absolute; z-index:2 ; left:-10px;top:12px"  border="0"   />';
  116. str +='</div></div>';
  117. var parentElm = elm1.parentNode;
  118. if(parentElm)
  119. {
  120. parentElm.innerHTML+=str;
  121. }
  122. var a = new Image();
  123. a.onload =  function(){ var elm = document.getElementById("num_"+id); if(elm){elm.src = a.src}}
  124. a.src = "2/" + image;
  125. oldelm1 = elm1;
  126. }
  127. else
  128. {
  129. }
  130. }