Javascript: 为其他框架中的输入框赋值在 MS Edge 中不起作用

Javascript: Assign value for input box in other frame not working in MS Edge

使用 MS Edge 查看时,我无法为位于其他框架中的输入框赋值。使用 IE 查看时没问题。所以,如果有任何问题,请指教workaround/solution。

这是一个展示问题的示例:http://thebeebs.github.io/so-35720658/

代码:

index.html 框架集:

<frameset rows="20%,*> id="run-detail-frame">
    <frame name="runDetailMain" id="runDetailMain" src="detail.html" ></frame>
    <frame name="runDetailSub" id="runDetailSub" src="custlist.html"></frame>
</frameset>

detail.html:

<html>
<head></head>
<body>
    <form name="routeForm">
        <input type="text" class="textbox" name="q_cust_no" size="40" maxlength="40">
        </form>
</body>

custlist.html:

<html>
<head></head>
<body>
   <button id="start">Click to fire function</button>
   <script>
       document.getElementById("start").onclick = function(){
           selectCustomer("Hello")

       }
       function selectCustomer(cust_cd){          
           parent.document.frames["runDetailMain"].routeForm.q_cust_no.value = cust_cd;               
       }
       </script>
</body>

将函数 selectCustomer 内的代码更改为:

parent.frames["runDetailMain"].routeForm.q_cust_no.value = cust_cd; 

在您的代码中,您正在调用 parent.document.frames.

我在 GitHub 上有一个包含工作代码的重现:https://github.com/thebeebs/so-35720658/tree/master/solution

还有一个工作演示:http://thebeebs.github.io/so-35720658/solution

调用 parent.document.frames 似乎在 IE 中有效,但在 Edge 和 Chrome 中无效。 Edge 最近做了很多更改,在行为与其他浏览器或标准不同的地方,Edge 团队选择删除行为而不是保持与 IE 的向后兼容性。