解决方案 »
- 如何用js控制标签隐藏和显示?
- Math.max(document.body.scrollWidth,document.documentElement.scrollWidth);
- JavaScript连接vrml需要插件,还是只是底层代码?
- firefox 中用JAVASCRIPT 请求WEBSERVICE
- 请教:有父窗口A,弹出子窗口B、C,如何在B中控制C的刷新?
- 问段代码
- 有谁知道360导航里“换一条”是怎么实现的吗?能不能给我段代码?
- 如何获取IE的title栏的背景色?
- 求一段javascript程序,类似自动滚屏
- 急急!!!树形目录的显示问题
- JS跳转到另一页面问题。
- 关于新浪网上的一个功能是如何实现的(onmouseover)
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
去掉看能不能正常显示
1、引用的js代码如下:
var imgwidth=700;
function $(id){return document.getElementById(id);}
function show(o){document.getElementById(o).style.display="block";}
function hide(o){document.getElementById(o).style.display="none";}
function geturl(url,id){
var http=false;
$(id).innerHTML='<span class="loading"> </span>';
if(window.XMLHttpRequest){http=new XMLHttpRequest();if(http.overrideMimeType){http.overrideMimeType('text/plain');}}else if(window.ActiveXObject){try{http=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{http=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){}}}
if(!http){alert('Cannot send an XMLHTTP request');return false;}
http.onreadystatechange=function(){if(http.readyState==4){$(id).innerHTML=http.responseText;}}
http.open("get", url, true);
http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
http.send(null);
}
function imgsize(){
var img=document.getElementById("content").getElementsByTagName("img");
for(var i=0; i<img.length;i++){
if(img[i].width>imgwidth){img[i].width=imgwidth;img[i].style.width=imgwidth;img[i].title="View";img[i].style.cursor="pointer";img[i].border=0;img[i].onclick=function(e){window.open(this.src);}}
}
}2、去掉<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 之后,菜单效果确实没问题,但是整个页面居左对齐,而不是按照DIV+CSS控制的居中对齐。
*{margin:0;padding:0;border:0;}
/* body{font-family:arial,宋体,serif;font-size:12px;}*/
#nav{width:1000px;height:43px;margin:0px; padding:0px;line-height:35px;list-style-type:none;background:url(/Images/Site_Navi_Bg1.gif) repeat-x;}#nav a{display:block;width:80px;text-align:center;}
#nav a:link{color:#666;text-decoration:none;}
#nav a:visited{color:#666;text-decoration:none;}
#nav a:hover{color:#FFF;text-decoration:none;font-weight:bold;}#nav li{float:left;width:80px;}
#nav li a:hover{background:#999;}
#nav li ul{margin:0px;line-height:35px;list-style-type:none;text-align:left;left:-999em;width:180px;position:absolute;}
#nav li ul li{float:left;width:180px;background:#F6F6F6;}
#nav li ul a{display:block;width:156px;text-align:left;padding-left:24px;}
#nav li ul a:link{color:#666;text-decoration:none;}
#nav li ul a:visited{color:#666;text-decoration:none;}
#nav li ul a:hover{color:#F3F3F3;text-decoration:none;font-weight:normal;background:#C00;}
#nav li:hover ul{left:auto;}
#nav li.sfhover ul{left:auto;}
#content{clear:left;}
<div class="kangfu" style="width:600px;text-align:right; font-size:30px; font-weight:bold; color:#333366">
已有<span style="color:#CC3333" id=kangfu>11300</span>人通过使用我们的产品得到康复</div>由于页面太长,就把其他部分略去了。
i=11200
function aa()
{if(i<11300)
i++
kangfu.innerText=i}
setTimeout('setInterval("aa()",1)',10);
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>主页</title>
<meta name="keywords" content="文章"/>
<meta name="description" content="文章"/>
<style>
.wrap *{margin:0;padding:0;border:0;}
body{padding:0;padding:0;font-family:arial,宋体,serif;font-size:12px;}
#nav{width:1000px;height:43px;margin:0px; padding:0px;line-height:35px;list-style-type:none;background:url(/Images/Site_Navi_Bg1.gif) repeat-x;}
#nav a{display:block;width:80px;text-align:center;}
#nav a:link{color:#666;text-decoration:none;}
#nav a:visited{color:#666;text-decoration:none;}
#nav a:hover{color:#FFF;text-decoration:none;font-weight:bold;}
#nav li{float:left;width:80px;}
#nav li a:hover{background:#999;}
#nav li ul{margin:0px;line-height:35px;list-style-type:none;text-align:left;left:-999em;width:180px;position:absolute;}
#nav li ul li{float:left;width:180px;background:#F6F6F6;}
#nav li ul a{display:block;width:156px;text-align:left;padding-left:24px;}
#nav li ul a:link{color:#666;text-decoration:none;}
#nav li ul a:visited{color:#666;text-decoration:none;}
#nav li ul a:hover{color:#F3F3F3;text-decoration:none;font-weight:normal;background:#C00;}
#nav li:hover ul{left:auto;}
#nav li.sfhover ul{left:auto;}
#content{clear:left;}
</style>
<script type="text/javascript">
var imgwidth=700;
function $(id){return document.getElementById(id);}
function show(o){document.getElementById(o).style.display="block";}
function hide(o){document.getElementById(o).style.display="none";}
function geturl(url,id){
var http=false;
$(id).innerHTML='<span class="loading"> </span>';
if(window.XMLHttpRequest){http=new XMLHttpRequest();if(http.overrideMimeType){http.overrideMimeType('text/plain');}}else if(window.ActiveXObject){try{http=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{http=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){}}}
if(!http){alert('Cannot send an XMLHTTP request');return false;}
http.onreadystatechange=function(){if(http.readyState==4){$(id).innerHTML=http.responseText;}}
http.open("get", url, true);
http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
http.send(null);
}
function imgsize(){
var img=document.getElementById("content").getElementsByTagName("img");
for(var i=0; i<img.length;i++){
if(img[i].width>imgwidth){img[i].width=imgwidth;img[i].style.width=imgwidth;img[i].title="View";img[i].style.cursor="pointer";img[i].border=0;img[i].onclick=function(e){window.open(this.src);}}
}
}</script><script language="javascript" defer>
var i = 11200;
function aa(){
if (i<11300) i++;
//kangfu.innerText=i
}
//setTimeout('setInterval("aa()",1)',10);
function menuFix(){
var sfEls = document.getElementById("nav").getElementsByTagName("li");
for(var i=0;i<sfEls.length;i++){
sfEls[i].onmouseover=function(){
this.className+=(this.className.length>0 ? " ":"") + "sfhover";
if(window.event){
var ul = this.getElementsByTagName("ul")[0];
if(ul) ul.style.left = "auto";
}
}
sfEls[i].onMouseDown=function(){
this.className+=(this.className.length>0 ? " ":"") + "sfhover";
}
sfEls[i].onMouseUp=function(){
this.className+=(this.className.length>0 ? " ":"") + "sfhover";
}
sfEls[i].onmouseout=function(){
this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"),"");
if(window.event){
var to = event.toElement;
var ul = this.getElementsByTagName("ul")[0];
if(ul) if(!ul.contains(to)) ul.style.left = "-999em";
}
}
}
}
window.onload = menuFix;
</script>
</head>
<body><div class="wrap">
<!--页头-->
<div class="head">
<table width="1000" height="173" border="0" cellpadding="0" cellspacing="0">
<tr><td><div><img src="/Images/logo.jpg" width="1000" height="173" /></div></td></tr>
</table>
</div> <!--菜单-->
<div>
<ul id="nav">
<li><a href="/" title="">首页</a></li>
<li><a href="/article/1/" title="产品展示">产品展示</a>
<ul>
<li><a href='/article/3/' title='Cardio'>Cardio</a></li>
<li><a href='/article/2/' title='Angio'>Angio</a></li>
</ul>
</li>
<li><a href="/article/4/" title="公司新闻">公司新闻</a></li>
<li><a href="/article/about.html" title="关于我们">关于我们</a></li>
<li><a href="/article/zhiliang.html" title="质量证明">质量证明</a></li>
<li><a href="/article/hospital.html" title="骨科医院">骨科医院</a></li>
<li><a href="/article/hr.html" title="招聘信息">招聘信息</a></li>
<li><a href="/article/daili.html" title="代理信息">代理信息</a></li>
<li><a href="/article/huanzhe.html" title="患者信息">患者信息</a></li>
<li><a href="/article/lianxiwomen.html" title="联系我们">联系我们</a></li>
<li><a href="/plus/search/" title="本站搜索">本站搜索</a></li>
</ul>
<!-- clear the floats if required -->
<div class="clear:both;"> </div>
</div></div>
</body></html>
只是加了两处代码(红色部分),程序就全活了,在ie7及其他浏览器测试通过!很好的解决了页面中!DOCTYPE和js函数function menuFix()代码之间的冲突bug:
<script language="javascript" defer>
function menuFix(){
var sfEls = document.getElementById("nav").getElementsByTagName("li");
for(var i=0;i<sfEls.length;i++){
sfEls[i].onmouseover=function(){
this.className+=(this.className.length>0 ? " ":"") + "sfhover";
if(window.event){
var ul = this.getElementsByTagName("ul")[0];
if(ul) ul.style.left = "auto";
}
}
sfEls[i].onMouseDown=function(){
this.className+=(this.className.length>0 ? " ":"") + "sfhover";
}
sfEls[i].onMouseUp=function(){
this.className+=(this.className.length>0 ? " ":"") + "sfhover";
}
sfEls[i].onmouseout=function(){
this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"),"");
if(window.event){
var to = event.toElement;
var ul = this.getElementsByTagName("ul")[0];
if(ul) if(!ul.contains(to)) ul.style.left = "-999em";
}
}
}
}
window.onload = menuFix;
</script> 再次表示感谢!