Home  >  Article  >  Web Front-end  >  Solve the following problem, HTML DIV layout_html/css_WEB-ITnose

Solve the following problem, HTML DIV layout_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:12:071240browse

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> 


Now we can basically achieve such an interface effect. ,, but why when I click the button on the left for the second time, the right side becomes blank. What is the problem?


Reply to the discussion (solution)

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>



Just do 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>


Just do this

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn