用 JavaScript 給站外連結的 cursor 進行改造_javascript技巧

來源:互聯網
上載者:User
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>用 JavaScript 給站外連結的 cursor 進行改造 - Beautiful Style « 樣式之美 » loaoao.com </title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="KEYWords" content="js,cursor,outlinks,links,jscc,css,xhtml,effect" /> <meta name="DEscription" content="用 JavaScript 給站外連結的 cursor 進行改造" /> <meta name="author" content="aoao" /> <meta content="all" name="robots" /> <link rel="start" href="http://www.loaoao.com" title="Home" /> <script type="text/javascript"> /* * Author:aoao * Homepage:http://www.loaoao.com * Email:loaoao@gmail.com / QQ:2222342 * Copyright (c) 2006 aoao * Licensed under a Creative Commons Attribution 2.5 License (http://creativecommons.org/licenses/by/2.5/) */ var jscc = new Object(); jscc = { init:function(){/*_*/}, path:"/scripts/jscc/", include:function (file){ var j=document.createElement("script"); j.setAttribute('type','text/javascript'); j.setAttribute('src',jscc.path+file+'.js'); document.getElementsByTagName("head")[0].appendChild(j); } }; jscc.addEvent = function( obj, type, fn ) { if ( obj.attachEvent ) { obj['e'+type+fn] = fn; obj[type+fn] = function(){obj['e'+type+fn]( window.event );} obj.attachEvent( 'on'+type, obj[type+fn] ); } else { obj.addEventListener( type, fn, false ); } }; jscc.getPosition=function(e) { e = e || window.event; var cursor = {x:0, y:0}; if (e.pageX || e.pageY) { cursor.x = e.pageX; cursor.y = e.pageY; } else { cursor.x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft; cursor.y = e.clientY + (document.documentElement.scrollTop ||document.body.scrollTop) - document.documentElement.clientTop; } return cursor; }; jscc.widgets = {/**/}; jscc.widgets.outLinks={ init:function(){ var outSiteIcon = document.createElement("div"); outSiteIcon.setAttribute('id','outSiteIcon'); document.getElementsByTagName("body").item(0).appendChild(outSiteIcon); outSiteIcon.innerHTML=""; var as = document.getElementsByTagName("a"); aslen = as.length; var url="http://lab.loaoao.com"; for(var i=0;i< aslen ;i++){ if (as[i].href.indexOf(url)&&as[i].href!=""){ //jscc.addEvent(as[i],"mouseover",jscc.widgets.outLinks.show); jscc.addEvent(as[i],"mousemove",jscc.widgets.outLinks.show); jscc.addEvent(as[i],"mouseout",jscc.widgets.outLinks.hide); //as[i].target = "_blank"; } } }, show:function(e){ if(e!=undefined){ var outSiteIcon = document.getElementById("outSiteIcon"); outSiteIcon.style.display="block"; cursorCoordinate = new jscc.getPosition(e); outSiteIcon.style.top=cursorCoordinate.y - 4 + "px"; outSiteIcon.style.left=cursorCoordinate.x + 5 + "px"; } }, hide:function(){ var outSiteIcon = document.getElementById("outSiteIcon"); outSiteIcon.style.display = "none"; } } window.onload = function(){ jscc.widgets.outLinks.init(); } </script> <style type="text/css"> #outSiteIcon{ position:absolute; z-index:99; display:none; } </style> </head> <body> <h1>用JavaScript給站外連結的cursor進行改造</h1> <p>因為是自己用的,沒把圖片路徑寫成變數存起來,連結測試:實驗室首頁,google。</p> <p>Copyright © 2006 aoao , Some Rights Reserved .</p> <!--統計代碼開始 --> <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script> <script type="text/javascript"> _uacct = "UA-600690-2"; urchinTracker(); </script> <!--統計代碼結束 --> </body> </html>
[Ctrl+A 全選 注:如需引入外部Js需重新整理才能執行]

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.