前端iframe标签的妙用

iframe基本使用:

iframe主要是在游览器的页面中划分出一部分地方用来放其他页面。

打个比方如果想在自己做的页面里面嵌入淘宝的首页,那就把src设置为淘宝的链接。记得要设置一下class样式,不然默认高度为0就不会显示出来了。

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>这是一个iframe</title>
	</head>
	<style type="text/css">
		*{
			padding: 0;
			margin: 0;
		}
		.iframe{
			width: calc(100% - 4px);
			height: calc(100vh - 8px);
		}
	</style>
	<body>
		<iframe id='iframe' class="iframe" src="https://www.taobao.com/" />
	</body>
</html>

另外我们可以利用iframe配合 实现多个网页的自动刷新。
例子:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>多个页面自动刷新</title>
	</head>
	<body>
	</body>
</html>
<html>
<head>
	<meta http-equiv="refresh" content="61"><!-- 实现游览器自动刷新,61秒一次 -->
</head>
<frameset>
<iframe src="https://www.taobao.com/" style="width: 100%;height: 300px;"></iframe>
<iframe src="https://www.taobao.com/" style="width: 100%;height: 300px;"></iframe>
<iframe src="https://www.taobao.com/" style="width: 100%;height: 300px;"></iframe>
<iframe src="https://www.taobao.com/" style="width: 100%;height: 300px;"></iframe>
<iframe src="https://www.taobao.com/" style="width: 100%;height: 300px;"></iframe>
<iframe src="https://www.taobao.com/" style="width: 100%;height: 300px;"></iframe>
</frameset>
</html>

这样自动刷新可以挂着自己csdn里的文章,给自己文章刷访问量,只要一运行就挂着就好了。虽然慢但是很好用绝对安全。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值