Home >Web Front-end >HTML Tutorial >Solve the following problem, HTML DIV layout_html/css_WEB-ITnose
Since I am doing a JSP job, I am simply building a system. The approximate interface is that there is a list of function links on the left, and then it is displayed on the right. I have never done HTML before, so I searched everywhere on the Internet for problems with DIV layout, links on the left, and display on the right. I saw the following solutions on the Internet:
<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>
Why? I hope you can guide me patiently.
Put a.href ="#"; Just remove it~~~
<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>
<!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>
<!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>
a.href="#"
After you click, you change the href attribute of a to #
It’s ok just like this
<!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>
It’s ok if you modify it like this. I haven’t been able to reply this morning~~~
<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>
Ouch, it sure works, let’s do it, it’s done