gpt4 book ai didi

javascript - 来自父级的 getElementById 适用于 Firefox,不适用于 IE

转载 作者:行者123 更新时间:2023-12-02 18:40:58 25 4
gpt4 key购买 nike

我正在尝试从父文档访问 Edge Animate 动画(这是一个菜单栏)中的元素。该元素有一个 onClick 事件,该事件根据父网页 URL 中的 #bookmark 触发。我的代码在 Firefox 中完美运行,但在 Internet Explorer(10) 中不起作用。 IE 无法看到“Stage”div 中的任何元素,而 Firefox 可以。

这是我父页面上的 JavaScript 代码:-

<script language='javascript'>

var thisPage = window.location.pathname;
var fullurl = document.URL;
var xxx = fullurl.substring(fullurl.indexOf('#'));
var pageString = xxx.replace("#", "");
pageString = pageString.replace("http://www.mydomain.com/portfolio/photography.html", "");

if (pageString == "corporate") {
window.onload = function() {
var iframe = document.getElementById('U10511_animation');
var innerDoc = (iframe.contentDocument) ?
iframe.contentDocument : iframe.contentWindow.document;

var corporateRectangle = innerDoc.getElementById('Stage_Corporate_Rectangle');
corporateRectangle.click();
}
};

</script>

当 URL 带有后缀 #corporate 时,上述代码将在 Firefox 中选择菜单中的 Corporate 选项卡,但在 IE 中则不会。

当我在 Firefox 中为变量“corporateRectangle”插入“警报”时,它返回 [HTMLObj],而在 IE 中它返回“null”。

有人有什么想法吗?谢谢。

最佳答案

您是否尝试过检查控制台是否存在某种错误,以帮助您和我们理解该错误?

关于javascript - 来自父级的 getElementById 适用于 Firefox,不适用于 IE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16845083/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com