查看框架的源代码

使用浏览器查看网页源代码时,发现有个选项【查看框架的源代码】,很好奇,这个是怎么来的。
探究了一番,出现这个选项需要两个条件:

  1. 浏览器支持(支持:谷歌、360安全浏览器极速模式、火狐,不支持:Edge)
  2. 网页中使用了<iframe><frameset> 标签

试验一下

index.html

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>mini_httpd test</title> 
</head>
<body>

<div id="container" style="width:500px">

<div id="header" style="background-color:#FFA500;">
<h1 style="margin-bottom:0;">主要的网页标题</h1></div>

<div id="menu" style="background-color:#FFD700;height:200px;width:100px;float:left;">
<b>菜单</b><br>
HTML<br>
CSS<br>
JavaScript</div>

<div id="content" style="background-color:#EEEEEE;height:200px;width:400px;float:left;">
内容在这里</div>

<p>
	aaa
</p>

</div>

<div width:550px;height:550px;>
	<iframe src="./test.html" width=550 height=550> </iframe>
</div>

</body>
</html>

text.html

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>mini_httpd test</title> 
</head>
<body>

<div id="container" style="width:500px">

<div id="header" style="background-color:#FFA500;">
<h1 style="margin-bottom:0;"> test 22222 </h1></div>

<div id="menu" style="background-color:#FFD700;height:200px;width:100px;float:left;">
<b>菜单</b><br>
HTML<br>
CSS<br>
JavaScript</div>

<div id="content" style="background-color:#EEEEEE;height:200px;width:400px;float:left;">
内容在这里</div>

</div>
 
</body>
</html>

在 index.html 页面中使用 iframe 标签将 test.html 页面包含进来,效果如下《查看框架的源代码》

    原文作者:Li-Yongjun
    原文地址: https://blog.csdn.net/lyndon_li/article/details/107857498
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞