建议下一个SWFObject的js库,才几十k
用里面的js方法添加flash,基本没有浏览器问题
如:wfobject.embedSWF("test.swf", "myContent", "300", "120", "9.0.0", "expressInstall.swf")
同样在js中,就可以控制上下位置拉
function Marquee(){ if(demo2.offsetWidth-demo.scrollLeft<=0)
demo.scrollLeft-=demo1.offsetWidth
else{ demo.scrollLeft++ }
}
上面这段代码控制横向滚动条滚动
var MyMar=setInterval(Marquee,speed)
上面这段代码让浏览器每30毫秒调用一次Marquee函数
也就是让滚动条滚动
demo.onmouseover=function()
{
clearInterval(MyMar)
}
上面这段代码让 当鼠标移动到demo控件上时停止调用Marquee函数
也就是说,鼠标移动到demo控件上,滚动条不再滚动
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
上面这段代码 当鼠标从demo控件上移开始,继续每30毫秒调用一次Marquee函数
也就是让滚动条继续滚动
建立一个html文件,复制下面的内容,打开就可以看到效果了<html>
<head>
<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312" />
</head>
<body>
<DIV id=img1 style="Z-INDEX: 100LEFT: 2pxWIDTH: 59pxPOSITION: absoluteTOP: 43pxHEIGHT: 61px
visibility: visible"><a href="http://www.baidu.com/" target="_blank"><img src="aaa.gif" width="80" height="80" border="0"></a></DIV>
<script type="text/javascript">
var xPos = 300
var yPos = 200
var step = 1
var delay = 30
var height = 0
var Hoffset = 0
var Woffset = 0
var yon = 0
var xon = 0
var pause = true
var interval
img1.style.top = yPos
function changePos()
{
width = document.body.clientWidth
height = document.body.clientHeight
Hoffset = img1.offsetHeight
Woffset = img1.offsetWidth
img1.style.left = xPos + document.body.scrollLeft
img1.style.top = yPos + document.body.scrollTop
if (yon)
{yPos = yPos + step}
else
{yPos = yPos - step}
if (yPos <0)
{yon = 1yPos = 0}
if (yPos >= (height - Hoffset))
{yon = 0yPos = (height - Hoffset)}
if (xon)
{xPos = xPos + step}
else
{xPos = xPos - step}
if (xPos <0)
{xon = 1xPos = 0}
if (xPos >= (width - Woffset))
{xon = 0xPos = (width - Woffset) }
}
function start()
{
img1.visibility = "visible"
interval = setInterval('changePos()', delay)
}
function pause_resume()
{
if(pause)
{
clearInterval(interval)
pause = false}
else
{
interval = setInterval('changePos()',delay)
pause = true
}
}
start()
</script>
</body>
</html>