window.open 副屏窗口
window.opener 主屏窗口
测试效果如下
js 调用双屏设备
js 调用双屏设备

zhu.html

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>主屏</title>
	</head>
	<body>
		这里是主屏
		<button onclick="daKaiFu()">打开副屏</button>
		<button onclick="diaoYongFu('HelloWorld')">调用副屏函数</button>
		
		<script>
			var fu = "";
			
			function daKaiFu(){
				fu = window.open("fu.html","","fullscreen=1,secondscreen=1,screenindex=1");
			}
			
			function diaoYongFu(val){
				if(!fu) {
					alert("请先打开副屏");
					return;
				}
				
				fu.fuFunction(val);
			}
		</script>
	</body>
</html>

fu.html

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>副屏</title>
	</head>
	<body>
		这里是副屏
		
		<script>
			function fuFunction(val){
				alert("副屏的函数被调用了 值为:" + val);
			}
		</script>
	</body>
</html>

相关文章:

  • 2021-09-17
  • 2022-12-23
  • 2022-12-23
  • 2022-01-16
  • 2022-12-23
  • 2021-08-05
  • 2022-01-26
  • 2022-02-22
猜你喜欢
  • 2022-01-27
  • 2021-09-26
  • 2021-04-30
  • 2022-01-20
  • 2022-12-23
  • 2022-01-22
  • 2021-07-14
相关资源
相似解决方案