[英]Is it possible to click a button on a html page from a separate html page?
I have two custom html pages: 'first.html' and 'second.html'. 我有两个自定义html页面:“ first.html”和“ second.html”。 In 'second.html' I have a hidden div.
在“ second.html”中,我有一个隐藏的div。 I want to click a button on 'first.html' that will unhide the div in 'second.html'.
我想单击“ first.html”上的按钮,以取消隐藏“ second.html”中的div。 I want both pages to be open at the same time in different windows/tabs.
我希望在不同的窗口/选项卡中同时打开两个页面。
This is a Django project so I tried to create a def in views.py that will open 'second.html' when the button on 'first.html' is opened. 这是一个Django项目,因此我尝试在views.py中创建一个定义,当打开“ first.html”上的按钮时,该定义将打开“ second.html”。 Doing this will just open 'second.html', but I need both pages to be opened at the same time.
这样做只会打开“ second.html”,但是我需要同时打开两个页面。
This sounds a bit weird, but sure. 这听起来有些奇怪,但可以肯定。 I can think of two ways to do it:
我可以想到两种方法:
Have first.html
open second.html
using window.open()
. 使用
window.open()
first.html
打开second.html
。 This gives first.html
full access to the DOM of second.html
. 这使
first.html
完全访问second.html
的DOM。
Communicate through the server. 通过服务器进行通信。
first.html
tells the server the button has been clicked. first.html
告诉服务器该按钮已被单击。 second.html
is listening, maybe with EventSource and updates it's DOM. second.html
正在监听,也许正在使用EventSource并更新它的DOM。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.