键盘隐藏和执行链接

发布于 2024-12-08 18:23:31 字数 246 浏览 0 评论 0原文

我在 html 代码中有一个链接,其中有 onclick 事件。

<a href="#" onclick="hidePopup();">Click</a>

填充文本后,当我单击 Click-link 时,键盘会隐藏,但 onclick 事件不会调用,然后我需要再次单击 click-link 来执行其事件。如何隐藏键盘并单击执行代码?

注意:链接位于 iframe 中。

I have a link in html code for which there is onclick event.

<a href="#" onclick="hidePopup();">Click</a>

After filling the text when I click the Click-link the keyboard hides but onclick event does not call, then I need to click the click-link again to execute its event. How to hide keyboard and execute code on single click?

Note: the link is in iframe.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

纸短情长 2024-12-15 18:23:31

我不确定我是否正确理解你的情况。我首先想到的是,您的 hidePopup() 函数是在主框架中定义的,您的链接位于 iframe 中,当您单击链接时,不会调用该函数。如果这是正确的,请尝试 window.parent.hidePopup() 而不是 hidePopup()。所以你的锚标记应该是

<a href="#" onclick="window.parent.hidePopup();">Click</a>

I am not sure if I understand your situation correctly. The first thing that comes to my mind is that your hidePopup() function is defined in the main frame and your link is in the iframe and when you click on the link this function doesn't get called. If this is correct try window.parent.hidePopup() instead of hidePopup(). So you anchor tag should be

<a href="#" onclick="window.parent.hidePopup();">Click</a>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文