本文介绍了图像交换仅适用于IE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个投资组合页面,可以加载十几个缩略图和一个大图像。

一个朋友帮我编写了一个脚本(下面),它将换掉大图像

(单击不同的缩略图时命名为imgLarg)。缩略图

和放大器的名字相同,一个在/ thumbs /中,一个在

/放大/ - 棘手,是吧? ;-)最简单的方法是什么?在其他浏览器中也可以使用



< script language =" JavaScript"> ;

函数放大(){

oSrcElem = event.srcElement;

imgLarge.src = oSrcElem.src.replace(/ thumbs /, ''images'');

}

< / script>

谢谢,

Wm

I have a portfolio page which loads a dozen thumbnails and one large image.
A friend helped me code a script (below) which will swap out the large image
(named "imgLarg") when a different thumbnail is clicked. Both the thumbnail
and the enlargement are identically named, one is in /thumbs/ and one is in
/enlargements/ - tricky, huh? ;-) What''s the easiest way to make this work
in other browsers as well?

<script language="JavaScript">
function enlarge() {
oSrcElem = event.srcElement;
imgLarge.src = oSrcElem.src.replace(/thumbs/,''images'');
}
</script>
Thanks,
Wm

推荐答案




根本不使用它,因为它是垃圾。比较


< URL:http://pointedears.de/scripts/test/hoverMe>

PointedEars



Not to use it at all, because it is junk. Compare

<URL:http://pointedears.de/scripts/test/hoverMe>
PointedEars




根本不使用它,因为它是垃圾。比较

< URL:http://pointedears.de/scripts/test/hoverMe>

PointedEars



Not to use it at all, because it is junk. Compare

<URL:http://pointedears.de/scripts/test/hoverMe>
PointedEars





在编译上面的时候,我觉得可以使用它:


功能放大(oSrcElem)

{

if(!imgLarge&& document.getElementById ){

var imgLarge = document.getElementById(''imgLarge'');

}

if(imgLarge){

imgLarge.src = oSrcElem.src.replace(/ thumbs /,''images'');

}

}

未经测试。当然,没有脚本的人都不会发生任何事情。


1.在这里阅读不同的事件模型:


< URL:http: //www.quirksmode.org/js/introevents.html>

-

Rob


While compiling the above, it occurred to me that it may be OK to use:

function enlarge (oSrcElem)
{
if (!imgLarge && document.getElementById){
var imgLarge = document.getElementById(''imgLarge'');
}
if (imgLarge){
imgLarge.src = oSrcElem.src.replace(/thumbs/,''images'');
}
}
Untested. Of course anyone without scripting will see nothing happen.

1. Read about the different event models here:

<URL:http://www.quirksmode.org/js/introevents.html>
--
Rob


这篇关于图像交换仅适用于IE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 21:53