H5 嵌套iframe并设置全屏

本文介绍了如何在H5页面中使用嵌套IFrame,并设置了全屏模式,同时展示了如何获取设备信息,适用于uni-app开发环境中的页面布局和交互设计。
摘要由CSDN通过智能技术生成

H5 嵌套iframe并设置全屏

  1. 上图上代码
    在这里插入图片描述
<template>
	<view class="mp-large-screen-box">
		<view class="mp-large-screen-count">
			<view class="mp-mini-btn-color mp-box-count" hover-class="mp-mini-btn-hover" @click="clickLeft">
				<uni-icons type="left" size="18" color="#ffffff"></uni-icons>
			</view>
			<iframe class="mp-iframe" :src="ptzUrl" frameborder="0" :style="`width: ${dataInfos.windowHeight}px;
				height: ${dataInfos.windowWidth}px;
				position: absolute;
				top: -${dataInfos.windowWidth}px;
				left: 0;transform: rotate(90deg);transform-origin:0 ${dataInfos.windowWidth}px;pointer-events: none;`"></iframe>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				dataInfos: {}, // 获取设备信息
			}
		},
		props: {
			showPtz: {
				type: String,
				default: () => '',
			},
			// 视频流
			ptzUrl: {
				type: String,
				default: () => '',
			},
		},
		mounted() {
			let that = this
			// 获取状态栏高度
			uni.getSystemInfo({
				success: function(e) {
					console.log(e, '传参设备')
					that.dataInfos = e
				},
			})
		},
		methods: {
			// 返回上一页
			clickLeft() {
				this.$emit('callbackFun')
			},
		},
	}
</script>
<style scoped lang="scss">
	.mp-large-screen-box {
		width: 100%;
		height: 100%;

		.uni-navbar__content {
			border-bottom: 0;
		}
	}

	.mp-large-screen-count {
		width: 100%;
		height: 100%;
	}

	.mp-iframme {
		width: 100%;
		height: 100%;
	}

	.mp-btn {
		position: absolute;
		top: 90%;
		right: 10px;
		width: 32px;
		height: 32px;
		display: flex !important;
		justify-content: center !important;
		align-items: center !important;
		padding: 0 !important;
	}

	.mp-mini-btn-color {
		margin-top: 14px;
		position: fixed;
		display: block;
		padding-left: 14px;
		padding-right: 14px;
		box-sizing: border-box;
		font-size: 18px;
		text-align: center;
		text-decoration: none;
		border-radius: 5px;
		overflow: hidden;
		cursor: pointer;
		line-height: 36px;
		font-size: 14px;
		background-color: var(--mp-primary);
		border-color: var(--mp-primary);
		color: #fff;
		bottom: 30px;
		width: 36px;
		height: 36px;
		right: 20px;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.mp-mini-btn-hover {
		animation: var(--mp-primary-light-10);
	}

	.mp-box-count {
		transform: rotate(90deg);
		position: absolute;
		right: 30px;
		z-index: 100 !important;
		top: 10px;
	}
</style>
  1. 搞定!(日常记录)
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要使网页进入全屏模式,可以使用 HTML5 提供的 Fullscreen API。以下是一种常见的实现方法: HTML 代码: ```html <button id="fullscreen-btn">进入全屏</button> ``` JavaScript 代码: ```javascript const fullscreenBtn = document.getElementById('fullscreen-btn'); fullscreenBtn.addEventListener('click', () => { const docEl = document.documentElement; if (docEl.requestFullscreen) { docEl.requestFullscreen(); } else if (docEl.mozRequestFullScreen) { // Firefox docEl.mozRequestFullScreen(); } else if (docEl.webkitRequestFullscreen) { // Chrome, Safari and Opera docEl.webkitRequestFullscreen(); } else if (docEl.msRequestFullscreen) { // IE/Edge docEl.msRequestFullscreen(); } }); ``` 在上述代码中,我们首先定义了一个 `<button>` 元素,并添加了一个点击事件监听器。 在事件处理函数中,我们首先获取 `document.documentElement`,即整个文档的根元素。然后,我们使用不同浏览器提供的全屏方法来请求进入全屏模式。根据不同的浏览器,我们可以使用 `requestFullscreen()`、`mozRequestFullScreen()`、`webkitRequestFullscreen()` 或 `msRequestFullscreen()` 方法。 当用户点击按钮时,会触发事件处理函数,并通过调用适当的全屏方法来请求进入全屏模式。 请注意,在某些浏览器中,进入全屏模式可能需要用户的交互操作,例如在按下按钮后,用户需要点击浏览器的全屏提示。此外,退出全屏模式可以使用 `document.exitFullscreen()`、`document.mozCancelFullScreen()`、`document.webkitExitFullscreen()` 或 `document.msExitFullscreen()` 方法。 需要注意的是,进入全屏模式具有浏览器兼容性问题,不同浏览器可能会有不同的前缀和要求。因此,建议在实际开发中使用现有的全屏模式库或框架,以确保在各种浏览器和设备上获得一致的体验。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值