Heim  >  Artikel  >  Web-Frontend  >  新页面打开实际尺寸的图片_图象特效

新页面打开实际尺寸的图片_图象特效

WBOY
WBOYOriginal
2016-05-16 19:27:04990Durchsuche
复制代码 代码如下:

<script> <BR><!-- <BR>var imgObj; <BR>function checkImg(theURL,winName){ <BR> if (typeof(imgObj) == "object"){ <BR> // 是否已取得了图像的高度和宽度 <BR> if ((imgObj.width != 0) && (imgObj.height != 0)) <BR> // 根据取得的图像高度和宽度设置弹出窗口的高度与宽度,并打开该窗口 <BR> // 其中的增量 20 和 30 是设置的窗口边框与图片间的间隔量 <BR> OpenFullSizeWindow(theURL,winName, ",width=" + (imgObj.width+20) + ",height=" + (imgObj.height+30)); <BR> else <BR> // 因为通过 Image 对象动态装载图片,不可能立即得到图片的宽度和高度,所以每隔100毫秒重复调用检查 <BR> setTimeout("checkImg('" + theURL + "','" + winName + "')", 100) <BR> } <BR>} <br><br>function OpenFullSizeWindow(theURL,winName,features) { <BR> var aNewWin, sBaseCmd; <BR> // 弹出窗口外观参数 <BR> sBaseCmd = "toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,"; <BR> // 调用是否来自 checkImg <BR> if (features == null || features == ""){ <BR> // 创建图像对象 <BR> imgObj = new Image(); <BR> // 设置图像源 <BR> imgObj.src = theURL; <BR> // 开始获取图像大小 <BR> checkImg(theURL, winName) <BR> } <BR> else{ <BR> // 打开窗口 <BR> aNewWin = window.open(theURL,winName, sBaseCmd + features); <BR> // 聚焦窗口 <BR> aNewWin.focus(); <BR> } <BR>} <BR>//--> <BR></script>


使用时将上面的代码放在网页文档的标记对中,然后在链接的点击事件中调用OpenFullSizeWindow函数,如新页面打开实际尺寸的图片_图象特效即可
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn