Artificial Intelligence Programming Lab(AIPLab) 討論區

97學年(上)課程2008Autumn => 網頁程式設計 => 主題作者是: fracchu 於 四月 01, 2009, 06:00:40 pm

主題: IE and Firefox move a div
作者: fracchu四月 01, 2009, 06:00:40 pm
程式碼: [Select]
<script type="text/javascript">
IE = (document.all);
NS = (navigator.appName=="Netscape");

function MoveDiv(id, num){
  if (IE) {
    es.pixelLeft += num;}
  if (NS||NS6) {
    es.left = parseInt(es.left)+num+"px";}

Within IE, you can use the attribute pixelLeft of tag's style to move.
Within Firefox, you MUST use the attribute left instead of pixelLeft.
In addition, the unit "px" must be added after the number.