99、图片的左右移动

99、图片的左右移动

脚本说明:

把如下代码加入<body>区域中

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin

window.onerror = null;

 var bName = navigator.appName;

 var bVer = parseInt(navigator.appVersion);

 var NS4 = (bName == "Netscape" && bVer >= 4);

 var IE4 = (bName == "Microsoft Internet Explorer" && bVer >= 4);

 var NS3 = (bName == "Netscape" && bVer < 4);

 var IE3 = (bName == "Microsoft Internet Explorer" && bVer < 4);

 

//------------------C U S T O M I S E------------------------

 

 var img_path="http://javascript.internet.com/img/headerlogo.gif";

 var time_length =50; //Scroll delay in milliseconds

 var begin_pos = 265; //Start position of scroll hint

 

//-----------------------------------------------------------

 

var i=begin_pos;

var j=i;

var scroll_length = 350; //The scroll length

var original_time=time_length;

 

if (NS4 || IE4) {

 if (navigator.appName == "Netscape") {

 layerStyleRef="layer.";

 layerRef="document.layers";

 styleSwitch="";

 }else{

 layerStyleRef="layer.style.";

 layerRef="document.all";

 styleSwitch=".style";

 }

}

 

//SCROLL RIGHT

function scroll_right(layerName)

{

 if (NS4 || IE4)

 {

   if(i<(begin_pos+scroll_length))

   {

    eval(layerRef+'["'+layerName+'"]'+

    styleSwitch+'.visibility="visible"');

    eval(layerRef+'["'+layerName+'"]'+ styleSwitch+'.left="'+(i)+'"');

    i++;

    j++;

   }

  if(i==j)

  {

   setTimeout("scroll_right('"+layerName+"')",time_length);

  }

 }

}

 

//SCROLL LEFT

function scroll_left(layerName)

{

 if (NS4 || IE4)

 {

   if(i>(begin_pos-scroll_length))

   {

    eval(layerRef+'["'+layerName+'"]'+

    styleSwitch+'.visibility="visible"');

    eval(layerRef+'["'+layerName+'"]'+ styleSwitch+'.left="'+(i)+'"');

    i--;

    j--;

   }

  if(i==j)

  {

   setTimeout("scroll_left('"+layerName+"')",time_length);

  }

 }

}

 

function scroll_out()

{

 time_length=10000000000000;

}

 

function reset()

{

 time_length=original_time;

}

 

document.write('<div id="prem_hint" style="position:relative; left:' + begin_pos + '" class="prem_hint"><img src="1334.gif"></div><center><a href="#" class="link" onmouseover="javascript:reset(); scroll_left(&#39;prem_hint&#39;);" onmouseout="javascript:scroll_out();"><b><< 向左移动</b></a> <b>|</b> <a href="#" class="link" onmouseover="javascript:reset(); scroll_right(&#39;prem_hint&#39;);" onmouseout="javascript:scroll_out();"><b>向右移动 >></b></a></center>');

//  End -->

</script>

 

Write a comment

Comments: 0