open 动态修改img的onclick事件示例代码

2019-12-24,,,,,

复制代码 代码如下:
var imgsrc = document.getElementById("imgsrc").getElementsByTagName('img');
imgsrc[0].style.cursor="hand";
imgsrc[0].onclick = new Function( "openArticle('/RssCommServlet?catalogid=29')");
imgsrc[1].style.cursor="hand";
imgsrc[1].onclick = new Function( "openArticle('/RssCommServlet?catalogid=30')");
imgsrc[2].style.cursor="hand";
imgsrc[2].onclick = new Function( "openArticle('/RssCommServlet?catalogid=31')");

<!--
function openArticle(url)
{
if(url=='')
return;
var option = "";
window.open(url,'',option);
}
var isDOM = (document.getElementById ? true : false);
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);
function getRef(id)
{
if (isDOM) return document.getElementById(id);
if (isIE4) return document.all[id];
if (isNS4) return document.layers[id];
}
function openNotice(url,winOption)
{
if(url=='')
return;
window.open(url,'',winOption);
}
function openWin(url,left,top,width,height)
{
if(url=='')
return;
var winOption = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+width+",height="+height+",left="+left+",top="+top;
window.open(url,'',winOption);
return;
}
function openWin(url,left,top,width,height,resizable)
{
if(url=='')
return;
var winOption = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable="+resizable+",width="+width+",height="+height+",left="+left+",top="+top;
window.open(url,'',winOption);
return;
}
//-->

您可能感兴趣的文章:

  • 原生JS操作网页给p元素添加onclick事件及表格隔行变色
  • js onclick事件传参讲解
  • window.location.href = window.location.href 跳转无反应 a超链接onclick事件写法
  • A标签触发onclick事件而不跳转的多种解决方法
  • js给onclick事件赋值,动态传参数实例解说
  • js触发asp.net的Button的Onclick事件应用
  • jquery移除button的inline onclick事件(已测试及兼容浏览器)
  • jquery应该如何来设置改变按钮input的onclick事件
  • Asp.Net 不同的OnClick事件区别小结(onserverclick,onclientclick)
  • javascript 动态改变onclick事件触发函数代码
  • 为radio类型的INPUT添加客户端脚本(附加实现JS来禁用onClick事件思路代码)
  • javascript option onclick事件ie解决方案 兼容ie,firefox
  • javascript使用onclick事件改变选中行的颜色

《open 动态修改img的onclick事件示例代码.doc》

下载本文的Word格式文档,以方便收藏与打印。