谁能把下面的代码修改成符合w3c标准,也就是要符合<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">代码如下:<script language="javascript">
<!--
function keyDown(e)
{
if (event.srcElement.tagName=='IFRAME'
&& event.clientX==-1
&& event.clientY==-1
&& event.fromElement=='[object]')
{
var num = parseInt(shownum.innerHTML);
shownum.innerHTML = num + 1;
}
return false;
}
document.onmousemove=keyDown;
document.onmouseover=keyDown ;
document.onmouseout=keyDown ;
document.onblur=keyDown;
//-->
</script>点击IFrame中的次数:<div id="shownum">0</div>
<iframe name='ad_click' marginwidth="0"
marginheight="0" frameborder="0" scrolling="no"
src='http://www.csdn.net/' width="100"
height="100" style="width: 616px; height: 171px">
</iframe>
<!--
function keyDown(e)
{
if (event.srcElement.tagName=='IFRAME'
&& event.clientX==-1
&& event.clientY==-1
&& event.fromElement=='[object]')
{
var num = parseInt(shownum.innerHTML);
shownum.innerHTML = num + 1;
}
return false;
}
document.onmousemove=keyDown;
document.onmouseover=keyDown ;
document.onmouseout=keyDown ;
document.onblur=keyDown;
//-->
</script>点击IFrame中的次数:<div id="shownum">0</div>
<iframe name='ad_click' marginwidth="0"
marginheight="0" frameborder="0" scrolling="no"
src='http://www.csdn.net/' width="100"
height="100" style="width: 616px; height: 171px">
</iframe>
<iframe name='ad_click' marginwidth="0"
marginheight="0" frameborder="0" scrolling="no"
src='http://www.csdn.net/' width="100"
height="100" style="width: 616px; height: 171px">
</iframe> js代码是不用管的!
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head><body>
<script language="javascript">
<!--
function keyDown(e)
{
var
oEvt,
oTag,
oDiv;
if(typeof(e)=="undefined")
{
oEvt = event;
}
else
{
oEvt = e;
} if(typeof(oEvt.srcElement)=="object")
{
oTag = oEvt.srcElement;
}
else
{
oTag = oEvt.target;
}
oDiv = document.getElementById("shownum");
if(oTag.name == "ad_click")
{
var num = parseInt(oDiv.innerHTML);
oDiv.innerHTML = num + 1;
}
return false;
}document.onmouseover=keyDown ;
//-->
</script>进入IFrame中的次数:<div id="shownum">0</div>
<iframe name='ad_click' marginwidth="0"
marginheight="0" frameborder="0" scrolling="no"
src='http://192.168.0.88/fix' width="100"
height="100" style="width: 616px; height: 171px">
</iframe>
</body>
</html>
如果单纯这个应用,<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
这段代码当然不必保留,但是从整个论坛程序来说,没有上面这句是不行的所以问题在于怎么修改iframe和js代码,而不是去掉我上面那段代码,谢谢!
楼主看看这是不是你要的效果
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head><body>
<script language="javascript">
<!--
function keyDown(e)
{
var
oEvt,
oTag,
oDiv;
if(typeof(e)=="undefined")
{
oEvt = event;
}
else
{
oEvt = e;
} if(typeof(oEvt.srcElement)=="object")
{
oTag = oEvt.srcElement;
}
else
{
oTag = oEvt.target;
}
oDiv = document.getElementById("shownum");
if(oTag.name == "ad_click")
{
var num = parseInt(oDiv.innerHTML);
oDiv.innerHTML = num + 1;
}
return false;
}document.onmouseover=keyDown ;//-->
</script>进入IFrame中的次数:<div id="shownum">0</div>
<iframe name='ad_click' marginwidth="0"
marginheight="0" frameborder="0" scrolling="no"
src='http://csdn.net' width="100"
height="100" style="width: 616px; height: 171px">
</iframe>
</body>
</html>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" language="javascript">
<!--
function keyDown(e)
{ var num = parseInt(document.getElementById("shownum").value);
SetAdvListener(1)
document.getElementById("shownum").value = String(num + 1);
document.getElementById("shownum").focus();
if(navigator.userAgent.indexOf("MSIE")>0)
{
window.setTimeout("SetAdvListener();", 50, "javascript");
}
else
{
} return false;
}
function InitPage()
{
SetAdvListener();
}
function SetAdvListener(flag)
{
var elm = document.getElementById("ad_click") ;
if(flag==null)
{
if(navigator.userAgent.indexOf("MSIE")>0)
{
elm.attachEvent("onactivate", keyDown);
}
else
{
}
}
else
{
if(navigator.userAgent.indexOf("MSIE")>0)
{
elm.detachEvent("onactivate", keyDown);
}
else
{
}
}
}
//-->
</script>
<body onload="javascript:InitPage();">
<div>
<span>点击IFrame中的次数:</span>
<input id="shownum" readonly="readonly" type="text" value="0" style="BORDER: #666666 1px solid;width:50px;text-align:center;" />
</div>
<br />
<div>
<iframe id="ad_click" name='ad_click' marginwidth="0"
marginheight="0" frameborder="1" scrolling="no"
src='http://www.csdn.net/' width="100"
height="600" style="width: 1024px; height: 768px">
</iframe>
</div>
</head>
</html>
利用onactivate事件, 在IE下面能用, 非IE下不行
如果只是要统计广告点击的话, 可以用个透明层蒙在iframe上面, 这样变得很简单了
那么请问有什么语句可以屏蔽引入的DOCTYPE 吗