请教一个链接跳转的问题,谢谢
- HTML code
<!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><style type="text/css">#center{ MARGIN-RIGHT: auto; MARGIN-LEFT: auto; height:200px; background:#fff; width:400px; vertical-align:middle; line-height:200px; }</style><script language="javascript">function linkonclick(){ var links=document.getElementsByTagName('a'); for(var i=0;i<links.length;i++) { links[i].onclick=function(){ document.getElementById('center').style.display=""; }; }}window.onload=linkonclick;function alertcontent(){ document.getElementById('center').style.display="";}</script><body><div id="center" style="display:none"><img src="logo2.gif" /></div><a href="http://www.hao123.com" >test</a><a href="http://www.hao123.com" >dddd</a><input type="button" value="button" onclick="alertcontent()"/></body></html>
大家好,我想在点链接时显示图片,但是还没等到显示就已经跳转到别的页面去了,请教高手们,这个怎么控制啊,谢谢
[解决办法]
第一处
links[i].onclick=function(){
document.getElementById('center').style.display="";
window.open(this.rel,"_blank");//_blank 在新窗口打开 _self 在本页面打开,根据情况自己定吧
};
第二处
<a href="javascript:void(0)" rel="http://www.hao123.com">test</a>
<a href="javascript:void(0)" rel="http://www.hao123.com">dddd</a>
这样你看怎么样?
[解决办法]
想通过window.open控制对象
但是发现new_window.document.readyState操控不了,域名不同
[解决办法]
显示图片和跳转页面只能做到一个 不知道你这二者是个什么关系
[解决办法]