open 動態(tài)修改img的onclick事件示例代碼
更新時間:2013年11月13日 17:27:16 作者:
動態(tài)修改img的onclick事件,使用open也可輕松做到,下面有個不錯的示例,需要的朋友可以參考下
復(fù)制代碼 代碼如下:
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操作網(wǎng)頁給p元素添加onclick事件及表格隔行變色
- js onclick事件傳參講解
- window.location.href = window.location.href 跳轉(zhuǎn)無反應(yīng) a超鏈接onclick事件寫法
- A標(biāo)簽觸發(fā)onclick事件而不跳轉(zhuǎn)的多種解決方法
- js給onclick事件賦值,動態(tài)傳參數(shù)實(shí)例解說
- js觸發(fā)asp.net的Button的Onclick事件應(yīng)用
- jquery移除button的inline onclick事件(已測試及兼容瀏覽器)
- jquery應(yīng)該如何來設(shè)置改變按鈕input的onclick事件
- Asp.Net 不同的OnClick事件區(qū)別小結(jié)(onserverclick,onclientclick)
- javascript 動態(tài)改變onclick事件觸發(fā)函數(shù)代碼
- 為radio類型的INPUT添加客戶端腳本(附加實(shí)現(xiàn)JS來禁用onClick事件思路代碼)
- javascript option onclick事件ie解決方案 兼容ie,firefox
- javascript使用onclick事件改變選中行的顏色
相關(guān)文章
使用JS監(jiān)聽鍵盤按下事件(keydown event)
這篇文章主要介紹了使用JS監(jiān)聽鍵盤按下事件(keydown event),本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價值,需要的朋友可以參考下2019-11-11JavaScript折半查找(二分查找)算法原理與實(shí)現(xiàn)方法示例
這篇文章主要介紹了JavaScript折半查找(二分查找)算法原理與實(shí)現(xiàn)方法,結(jié)合具體問題描述了折半查找算法的原理、實(shí)現(xiàn)方法及相關(guān)操作注意事項(xiàng),需要的朋友可以參考下2018-08-08uniapp微信小程序訂閱消息發(fā)送服務(wù)通知超詳細(xì)教程
在使用或開發(fā)小程序過程中,我們會發(fā)現(xiàn)消息通知是非常重要的一個環(huán)節(jié),下面這篇文章主要給大家介紹了關(guān)于uniapp微信小程序訂閱消息發(fā)送服務(wù)通知的相關(guān)資料,需要的朋友可以參考下2023-06-06使用 JavaScript 進(jìn)行函數(shù)式編程 (一) 翻譯
本文是函數(shù)式編程系列的第一篇文章。這里我會簡要介紹一下編程范式,然后會直接介紹使用 Javascript 進(jìn)行函數(shù)式編程的概念,因?yàn)?JavsScript 是最被認(rèn)可的函數(shù)式程序語言之一。我們鼓勵讀者通過參考資料部分進(jìn)一步了解這一迷人的概念2015-10-10