可以用这种方式<HTML> <BODY ONLOAD="setupEventHandler()" LANGUAGE="VBS"> <SCRIPT LANGUAGE="VBS"> function setupEventHandler() set fpchgBackground = getRef("chgBackground") call mySpan.attachEvent("onclick", fpChgBackground) end function function chgBackground() document.bgColor = "lemonchiffon" end function </SCRIPT> <SPAN ID="mySpan">SPAN</SPAN> </BODY> </HTML> 这个是vbs,主要是就是利用object.attachEvent(sEvent, fpNotify) 参考: bSuccess = object.attachEvent(sEvent, fpNotify) ParameterssEvent: Required. String that specifies any of the standard DHTML Events. fpNotify: Required. Pointer that specifies the function to call when sEvent fires. Return ValueBoolean. Returns one of the following possible values:true The function was bound successfully to the event. false The function was not bound to the event.
<BODY ONLOAD="setupEventHandler()" LANGUAGE="VBS">
<SCRIPT LANGUAGE="VBS">
function setupEventHandler()
set fpchgBackground = getRef("chgBackground")
call mySpan.attachEvent("onclick", fpChgBackground)
end function
function chgBackground()
document.bgColor = "lemonchiffon"
end function
</SCRIPT>
<SPAN ID="mySpan">SPAN</SPAN>
</BODY>
</HTML>
这个是vbs,主要是就是利用object.attachEvent(sEvent, fpNotify)
参考:
bSuccess = object.attachEvent(sEvent, fpNotify)
ParameterssEvent: Required. String that specifies any of the standard DHTML Events.
fpNotify: Required. Pointer that specifies the function to call when sEvent fires. Return ValueBoolean. Returns one of the following possible values:true The function was bound successfully to the event.
false The function was not bound to the event.
var lkOptions=document.getElementById("prf_g");
lkOptions.onclick=function(){
document.location="www.x2blog.cn";
}
</script>
对象.onclick=function gonext()
{
document.location.href="http://www.csdn.net"
}
//文档加载完成后组prf_g绑定一个事件。
window.onload = function(){
document.getElementById("prf_g").onclick = function (){
location.href = "xxx.asp";
}}
</scriopt>
<script>
var sp = document.getElementById("prf_g");
sp.onclick=function(){
window.location.href = "http://www.baidu.com";
}
</script>
用上面的方法,在一个frame中,我要指向另外一个框架怎么做呢
<p><span class="lk" id="prf_g" onclick="self.parent.framename.location.href='http://www.baidu.com'">设置1</span></p>
为什么不直接用<a href="url">url</a>