日期:2014-05-17 浏览次数:20803 次
<html> <head> <title>DIV 跳转</title> <style> #container {margin:0 auto; width:100%;} #sidebar { float:left; width:200px; height:500px; background:#9c6;} * html #sidebar{margin-right:-3px;} #content { height:500px; background:#ffa;} </style> </head> <body> <div id="container"> <div id="sidebar"> <ul> <li> <a href="http://www.baidu.com" onclick="theforever(this);">百度</a></li> <li><a href="http://www.hao123.com" onclick="theforever(this);">好123</a></li> </ul> </div> <div id="content">为什么第二次点击链接的时候,显示空白啦??</div> </div> <script type="text/javascript"> function theforever(a){ document.getElementById('content').innerHTML='<iframe src="'+a.href+'" width=100% height=100%></iframe>'; a.href="#";} </script> </body> </html>
<!DOCTYPE HTML> <html> <head> <meta charset="gb2312" /> <title></title> </head> <body> <a href="http://baidu.com" target="test">百度</a> <a href="http://hao123.com" target="test">hao123</a> <iframe src="http://qq.com" name="test" frameborder="0"></iframe> </body> </html>
------解决方案--------------------
这样修改就ok啦,早上一直无法回复啊~~~
<html> <head> <title>DIV 跳转</title> <style> #container {margin:0 auto; width:100%;} #sidebar { float:left; width:200px; height:500px; background:#9c6;} * html #sidebar{margin-right:-3px;} #content { height:500px; background:#ffa;} </style> </head> <body> <div id="container"> <div id="sidebar"> <ul> <li> <a href="http://www.baidu.com" onclick="theforever(this);return false;">百度</a></li> <li><a href="http://www.hao123.com" onclick="theforever(this);return false;">好123</a></li> </ul> </div> <div id="content">为什么第二次点击链接的时候,显示空白啦??</div> </div> <script type="text/javascript"> function theforever(a){ document.getElementById('content').innerHTML='<iframe src="'+a.href+'" width=100% height=100%></iframe>'; } </script> </body> </html>