非常简单的 document.onmouseup 不适用于 IE

发布于 2024-09-14 16:58:36 字数 340 浏览 4 评论 0原文

嘿,我还有另一个非常简单的 JavaScript 问题...... 我有一个当点击链接时显示的 div。这没问题并且工作正常。然后,当鼠标单击页面上的任意位置时,我需要隐藏 div。再说一次,在 FF、Chrome、Safari 和 Opera 中没有问题,但在 IE 中却没有问题,它现在真的让我头疼(!)

这是我已经尝试过的主题的许多变体的代码

document.onmouseup = function()
{
  hide();
}

,到目前为止没有一个有效,即使有该功能只是发出警报,在 IE 中根本不起作用。我已经没有主意了!

任何帮助将不胜感激。干杯。

Hey, I have another incredibly simple JavaScript problem...
I have a div that is shown when a link is clicked on. That is no problem and working fine. I then need the div to be hidden when the mouse is clicked anywhere on the page. Again, no problem in FF,Chrome,Safari and Opera but not in IE and it is really doing my head in now(!)

Here is the code

document.onmouseup = function()
{
  hide();
}

I have tried many variations on the theme, none of which so far work, even having the function just give an alert will not work at all in IE. And I am running out of ideas!

Any help would be appreciated immensly. Cheers.

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

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

发布评论

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

评论(1

蓝咒 2024-09-21 16:58:36

我认为问题可能出在你的隐藏函数中。

如果你还没有使用某些默认显示样式创建 id DropdownShare0 的 div,则代码

if (elm.style.display == "block")< /strong>”将为 false,因为如果在创建元素时未设置任何内容,它将返回“未定义”,

因此也请检查一下。

I think the problem may be in your hide function..

If you haven't created the div with the id DropdownShare0 with some default display style, the code

"if (elm.style.display == "block")" will be false because if none is set when creating element it will return 'undefined'

So check that too..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文