Javascript 边中是否存在框架的测试

Javascript 边中是否存在框架的测试,javascript,microsoft-edge,Javascript,Microsoft Edge,除了Microsoft legacy Edge之外,我还有以下测试,可以在我测试过的所有浏览器中使用 var frame_name = window.parent.frames[1].name; if (window.parent[frame_name].frames[1].frames[1]) { //Edge thinks this is true, } 在legacyEdge中,即使它是假的,它也会进入其中。在Ch

除了Microsoft legacy Edge之外,我还有以下测试,可以在我测试过的所有浏览器中使用

        var frame_name = window.parent.frames[1].name;

        if (window.parent[frame_name].frames[1].frames[1]) {
           //Edge thinks this is true, 
        }
在legacyEdge中,即使它是假的,它也会进入其中。在Chrome等中,它认为这是不真实的。如果我查看边缘调试器工具中的值,我会看到:

window.parent[frame_name].frames[1].frames[1]   [object Window]
__proto__   [object WindowPrototype]
{error} Permission denied

是否有任何方法可以测试Edge中是否存在帧?

我尝试使用MS Edge legacy 44.18362.449.0版本进行测试,发现代码在其中运行良好

测试代码:

<!DOCTYPE html>
<html>
<head>

</head>
<body>

<h1>The iframe element</h1>

<iframe src="http://your_site/childpage.html">
</iframe>
<script>
if (window.parent.frames[1].frames[1]) {
   //Edge thinks this is true, 
   alert("found...");
   console.log(window.parent.frames[1].frames[1]);
}
else
{
alert("not forund...");
}
</script>
</body>
</html>
您还可以尝试按其ID或名称查找iframe,如下所示

<iframe src="http://your_site/childpage.html" id="frame1">
</iframe>

var element =  document.getElementById('frame1');
if (typeof(element) != 'undefined' && element != null)
{
   alert("found...");
}

var元素=document.getElementById('frame1');
if(typeof(element)!='undefined'&&element!=null)
{
警惕(“发现…”);
}

我对代码进行了调整,使之更接近我的实际代码。我还测试了修改后的代码,但在控制台中显示错误。发生错误的原因是帧[1]。帧[1]不可用。因此,边缘浏览器仍然显示正确的结果。我想与您确认用于进行此测试的Edge legacy browser的哪个版本?
<iframe src="http://your_site/childpage.html" id="frame1">
</iframe>

var element =  document.getElementById('frame1');
if (typeof(element) != 'undefined' && element != null)
{
   alert("found...");
}