?? 4.13 圖片跟隨鼠標.htm
字號:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>標題頁</title>
<SCRIPT LANGUAGE="JavaScript">
var newtop=0;
var newleft=0;
divStyleRef="layer.style.";
layerRef="document.all";
mystyle=".style";
function doMouseMove()
{
layerName = 'myimg'; //獲取包裝圖片的div
eval('var curElement='+layerRef+'["'+layerName+'"]');
eval(layerRef+'["'+layerName+'"]'+mystyle+'.visibility="hidden"');
eval('curElement'+mystyle+'.visibility="visible"');
//設置div的顯示位置-坐標和高度、寬度
eval('newleft=document.body.clientWidth-curElement'+mystyle+'.pixelWidth');
eval('newtop=document.body.clientHeight-curElement'+mystyle+'.pixelHeight');
eval('height=curElement'+mystyle+'.height');
eval('width=curElement'+mystyle+'.width');
width=parseInt(width);
height=parseInt(height);
//鼠標移出邊界時的div位置的判斷
if (event.clientX > (document.body.clientWidth - 5 - width))
{
newleft=document.body.clientWidth + document.body.scrollLeft - 5 - width;
}
else
{
newleft=document.body.scrollLeft + event.clientX;
}
eval('curElement'+mystyle+'.pixelLeft=newleft');
if (event.clientY > (document.body.clientHeight - 5 - height))
{
newtop=document.body.clientHeight + document.body.scrollTop - 5 - height;
}
else
{
newtop=document.body.scrollTop + event.clientY;
}
eval('curElement'+mystyle+'.pixelTop=newtop');
}
document.onmousemove = doMouseMove; //綁定鼠標移動事件
//動態輸出div和圖像-默認情況下圖像隱藏
document.write('<div ID=mydiv>');
document.write('<img ID=myimg src="LOGO1.gif" STYLE="position:absolute;TOP:0pt;LEFT:0pt;width=103;height=28;Z-INDEX:2;visibility:hidden;">')
document.write('</div>')
</SCRIPT>
</head>
<body>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -