iT邦幫忙

0

讀取滑鼠座標之設計問題

想請問document.Show.MouseX.value的MouseX和是指令還是只是個名稱而已
還有這段document.Show.MouseX.value是指說在網頁中名稱為Show的form標籤中利用設計出名稱為MouseX的input標籤顯示"值" 不知道這樣解釋對不對(有點難翻...)
小弟剛入門不久
請各位大大幫忙解答
謝謝
以下為我在網路上擷取的程式碼

<html xmlns="http://www.w3.org/1999/xhtml">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標題文件</title>
<style type="text/css">
 
</style>


<script type="text/javascript" language="javascript">





</script> 





<body  >

<script >
<!--
// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false;

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE);

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var tempX = 0;
var tempY = 0;

// Main function to retrieve mouse x-y pos.s

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft;
    tempY = event.clientY + document.body.scrollTop;
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX;
    tempY = e.pageY;
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  document.Show.MouseX.value = tempX;
  document.Show.MouseY.value = tempY;
  return true;
}


//-->
</script>
<form name="Show">
<p align="center"><input type="text" name="MouseX" value="0" size="4">X <input type="text" name="MouseY" value="0" size="4">Y </form>

  <!-------JavaScript顯示滑鼠所在座標 END-------->
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
sky940811
iT邦研究生 5 級 ‧ 2015-03-02 16:24:27

問:想請問document.Show.MouseX.value的MouseX和是指令還是只是個名稱而已
答:MouseX是名稱,document.Show.MouseX.value是指令

問:document.Show.MouseX.value是指說在網頁中名稱為Show的form標籤中利用設計出名稱為MouseX的input標籤顯示"值"
答:基本上和你解釋得差不多,就是抓取表單(Show)裡面的文字方塊(MouseX)控制該欄位的值,根據程式上的寫法,是讓該文字方塊顯示tempX抓取到的值

※若解釋有誤還請大大們給予糾正

我要發表回答

立即登入回答