43、文字从右向左移动,鼠标移上去停止

43、文字从右向左移动,鼠标移上去停止

要完成此效果需要三个步骤

 

第一步:把如下代码加入到<head>区域中

 

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin

var ostat = false;

function scrollstop() {

news.scrollAmount = 0;

ostat = true;

}

function scrollplay() {

news.scrollAmount = 5;

ostat = false;

}

function scrolldir() {

mid = screen.width / 2;

mouse = event.x;

if(mouse > mid) {

if(ostat == false) {

speed = (mouse - mid) / 25;

news.scrollAmount = speed;

}

news.direction = "right";

}

else {

if(ostat == false) {

speed = (mid - mouse) / 25;

news.scrollAmount = speed;

}

news.direction = "left";

   }

}

//  End -->

</script>

 

 

第二步:把如下代码加入到区域中

 

<marquee name=news id=news behavior=scroll direction=left scrollamount=5 scrolldelay=1 hspace=0 vspace=0 onmouseover="scrollstop()" onmouseout="scrollplay()">

<b>Welcome To Typhoon Start JavaScript Fairyland!</b>

</marquee>

 

 

第三步:把“onMouseMove="scrolldir()"”加在标记里

例如:

 

 

Write a comment

Comments: 0