简体   繁体   English

如何创建指向页面的链接并强制它立即执行 javascript

[英]How do I create a link to a page and force it to immediately execute a javascript

I need to open a specific view of a website.我需要打开网站的特定视图。 In fact the webpage is only one page and the links on the page execute javascript functions to change the visible content.实际上网页只有一页,页面上的链接执行javascript函数来改变可见内容。 My question is:我的问题是:

How can I create a link to this webpage that tells the page which javascript function to be executed in order for it to show the desired page view?如何创建指向此网页的链接,告诉页面要执行哪个 javascript 函数才能显示所需的页面视图?

If you're targeting modern browsers, you may use postMessage to send messages between windows.如果您的目标是现代浏览器,您可以使用postMessage在窗口之间发送消息。

https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage

You could be listening for messages on your main window while your popup send them.当您的弹出窗口发送消息时,您可能正在主窗口上收听消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM