|
主题: 请教大家一个JS代码问题,感谢回答!
|
枫影
职务:普通成员
等级:1
金币:0.0
发贴:17
|
#12004/11/12 20:55:23
www.5d.cn/rudolf/web/web-navi1-2.htm这个地址上面的那个左右移动的导航兰 我照着说明把代码移动到自己新建的html代码内,为<body> </body>之间,为什么就成了这样呢??? 如图: 图片如下: 郁闷 下面的是我的代码:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>无标题文档</title>
</head>
<body>
<style>body{
overflow-x: hidden;
overflow-y: scroll;
}
</style>
<script language=JavaScript1.2>
/*
Scrollable Menu Links- By Dynamicdrive.com
For full source, TOS, and 100s DTHML scripts
Visit http://dynamicdrive.com
*/
//配置左右箭头路径
var goleftimage='pointer2.gif'
var gorightimage='pointer.gif'
//配置菜单宽度
var menuwidth=300
//定义滚动速度(1-10),越大越快
var scrollspeed=6
//定义菜单内容
var menucontents='<nobr><a href="http://www.dynamicdrive.com">Dynamic Drive</a> | <a href="http://wsabstract.com">Website Abstraction</a> | <a href="http://www.codearena.com">CodeArena.com</a> | <a href="http://www.builder.com">Builder.com</a> | <a href="http://freewarejava.com">Freewarejava.com</a></nobr>'
////NO NEED TO EDIT BELOW THIS LINE////////////
var actualwidth=''
var ns_scroll
function fillup(){
if (document.all){
test2.innerHTML=menucontents
actualwidth=test2.offsetWidth
}
else if (document.layers){
ns_scroll=document.ns_scrollmenu.document.ns_scrollmenu2
ns_scroll.document.write(menucontents)
ns_scroll.document.close()
actualwidth=ns_scroll.document.width
}
}
window.onload=fillup
function moveleft(){
if (document.all&&test2.style.pixelLeft>(menuwidth-actualwidth))
test2.style.pixelLeft-=scrollspeed
else if (document.layers&&ns_scroll.left>(menuwidth-actualwidth))
ns_scroll.left-=scrollspeed
lefttime=setTimeout("moveleft()",50)
}
function moveright(){
if (document.all&&test2.style.pixelLeft<0)
test2.style.pixelLeft+=scrollspeed
else if (document.layers&&ns_scroll.left<0)
ns_scroll.left+=scrollspeed
righttime=setTimeout("moveright()",50)
}
if (document.all||document.layers){
with (document){
write('<table border="0" cellspacing="0" cellpadding="0">')
write('<td valign="middle"><a href=#" onMouseover="moveleft()" onMouseout="clearTimeout(lefttime)"><img src="'+goleftimage+'"border=0></a> </td>')
write('<td valign="top">')
if (document.all){
write('<span style="position:relative;width:'+menuwidth+';">')
write('<span style="position:absolute;width:'+menuwidth+';clip:rect(0 '+menuwidth+' auto 0)">')
write('<span id="test2" style="position:absolute;left:0;top:0">')
write('</span></span></span>')
}
else if (document.layers){
write('<ilayer width='+menuwidth+' name="ns_scrollmenu">')
write('<layer name="ns_scrollmenu2" left=0 top=0></layer></ilayer>')
}
write('</td>')
write('<td valign="middle"> <a href="#" onMouseover="moveright()" onMouseout="clearTimeout(righttime)">')
write('<img src="'+gorightimage+'"border=0></a>')
write('</td></table>')
}
}
</script>
</body>
</html>
|
枫影
职务:普通成员
等级:1
金币:0.0
发贴:17
|
#22004/11/12 21:01:52
我要怎么做才能让代码现在在一个长571,宽125的表格里面呢??? 如图: 图片如下: 就是这么大的表格。 如下是表格代码:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>表格测试专用</title>
<style type="text/css">
<!--
body,td,th {
font-family: 宋体;
font-size: 12px;
}
-->
</style>
<link href="css.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="571" height="125" border="1" cellpadding="0" cellspacing="0">
<tr>
<td> </td>
</tr>
</table>
</body>
</html>
|
枫影
职务:普通成员
等级:1
金币:0.0
发贴:17
|
#32004/11/13 11:46:01
UP一下。。。。。。。。
|
枫影
职务:普通成员
等级:1
金币:0.0
发贴:17
|
#42004/11/16 16:26:48
..............................
|
枫影
职务:普通成员
等级:1
金币:0.0
发贴:17
|
#52004/11/17 10:27:16
求不到死不罢休
|
风之密码
职务:普通成员
等级:2
金币:2.0
发贴:398
|
#62004/11/17 11:15:12
我想你缺少了文件头
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Untitled Document</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<STYLE type=text/css>.myFont {
FONT-SIZE: 10.5pt; LINE-HEIGHT: 150%
}
</STYLE>
<META content="MSHTML 6.00.2900.2180" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff>
<P>
<STYLE>BODY {
OVERFLOW-Y: scroll; OVERFLOW-X: hidden
}
</STYLE>
<SCRIPT language=JavaScript1.2>
/*
Scrollable Menu Links- By Dynamicdrive.com
For full source, TOS, and 100s DTHML scripts
Visit http://dynamicdrive.com
*/
//配置左右箭头路径
var goleftimage='pointer2.gif'
var gorightimage='pointer.gif'
//配置菜单宽度
var menuwidth=300
//定义滚动速度(1-10),越大越快
var scrollspeed=6
//定义菜单内容
var menucontents='<nobr><a href="http://www.dynamicdrive.com">Dynamic Drive</a> | <a href="http://wsabstract.com">Website Abstraction</a> | <a href="http://www.codearena.com">CodeArena.com</a> | <a href="http://www.builder.com">Builder.com</a> | <a href="http://freewarejava.com">Freewarejava.com</a></nobr>'
////NO NEED TO EDIT BELOW THIS LINE////////////
var actualwidth=''
var ns_scroll
function fillup(){
if (document.all){
test2.innerHTML=menucontents
actualwidth=test2.offsetWidth
}
else if (document.layers){
ns_scroll=document.ns_scrollmenu.document.ns_scrollmenu2
ns_scroll.document.write(menucontents)
ns_scroll.document.close()
actualwidth=ns_scroll.document.width
}
}
window.onload=fillup
function moveleft(){
if (document.all&&test2.style.pixelLeft>(menuwidth-actualwidth))
test2.style.pixelLeft-=scrollspeed
else if (document.layers&&ns_scroll.left>(menuwidth-actualwidth))
ns_scroll.left-=scrollspeed
lefttime=setTimeout("moveleft()",50)
}
function moveright(){
if (document.all&&test2.style.pixelLeft<0)
test2.style.pixelLeft+=scrollspeed
else if (document.layers&&ns_scroll.left<0)
ns_scroll.left+=scrollspeed
righttime=setTimeout("moveright()",50)
}
if (document.all||document.layers){
with (document){
write('<table border="0" cellspacing="0" cellpadding="0">')
write('<td valign="middle"><a href=#" onMouseover="moveleft()" onMouseout="clearTimeout(lefttime)"><img src="'+goleftimage+'"border=0></a> </td>')
write('<td valign="top">')
if (document.all){
write('<span style="position:relative;width:'+menuwidth+';">')
write('<span style="position:absolute;width:'+menuwidth+';clip:rect(0 '+menuwidth+' auto 0)">')
write('<span id="test2" style="position:absolute;left:0;top:0">')
write('</span></span></span>')
}
else if (document.layers){
write('<ilayer width='+menuwidth+' name="ns_scrollmenu">')
write('<layer name="ns_scrollmenu2" left=0 top=0></layer></ilayer>')
}
write('</td>')
write('<td valign="middle"> <a href="#" onMouseover="moveright()" onMouseout="clearTimeout(righttime)">')
write('<img src="'+gorightimage+'"border=0></a>')
write('</td></table>')
}
}
</SCRIPT>
</P>
</BODY></HTML>
|