Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 从子窗口访问父窗口id 我有一个名为eventLog.jsp的父窗口 和一个名为processManager.jsp的子窗口 父窗口有一个按钮,单击该按钮时,它将调用函数getEventLogProcess() getEventLogProcess()将打开弹出窗口(processManager.jsp/child window) 我的需要是,我必须在子窗口的加载功能中获取父窗口按钮id_Javascript_Dojo - Fatal编程技术网

Javascript 从子窗口访问父窗口id 我有一个名为eventLog.jsp的父窗口 和一个名为processManager.jsp的子窗口 父窗口有一个按钮,单击该按钮时,它将调用函数getEventLogProcess() getEventLogProcess()将打开弹出窗口(processManager.jsp/child window) 我的需要是,我必须在子窗口的加载功能中获取父窗口按钮id

Javascript 从子窗口访问父窗口id 我有一个名为eventLog.jsp的父窗口 和一个名为processManager.jsp的子窗口 父窗口有一个按钮,单击该按钮时,它将调用函数getEventLogProcess() getEventLogProcess()将打开弹出窗口(processManager.jsp/child window) 我的需要是,我必须在子窗口的加载功能中获取父窗口按钮id,javascript,dojo,Javascript,Dojo,eventLog.jsp: <div class="claro" id="menuDiv141" onclick="setWidgetproperty(this.id,'x','navMenu141');" onmousedown="setMenuBarProperty('navMenu141');" onmouseup="setDocStyle(this.id)" style="border:1px dotted white; left: auto; position: absolute

eventLog.jsp:

<div class="claro" id="menuDiv141" onclick="setWidgetproperty(this.id,'x','navMenu141');" onmousedown="setMenuBarProperty('navMenu141');" onmouseup="setDocStyle(this.id)" style="border:1px dotted white; left: auto; position: absolute; top: 620px;">
     <div dojotype="dijit.MenuBar" id="navMenu141" style="font-size:11pt;" title="MenuBar">
          <div dojotype="dijit.MenuBarItem" id="SearchMenu141" onclick="getEventLogProcess();setMenuId(this.id);" style="font-size:11pt;" title="menuBarItem">
               <img class="images" id="SearchMenu141" name="search5.png" onclick="setImgProperty(this.id)" src="images/uploads/search.png" style="height:20px; width:20px;">
               Search
          </div>
</div>
</div>

我觉得你的代码太复杂了,所以我写了一个测试脚本:

父窗口

函数foo(){
window.buttonid=document.getElementById('button1');
打开(“childwindow.html”,“子窗口”);
}
点击这里
子窗口

函数加载(){
警报(window.opener.buttonid.name);
}

有人能回答我的问题吗。。。请您也可以从子窗口访问父窗口的按钮id,如:window.opener.document.getElementById(“button1”);如何使用
window.opener
访问子窗口中的父窗口dojo小部件(非普通元素)?
function getEventLogProcess(){
    if(dijit.byId('dynamiceventgridCWPROCESSEVENTLOG')){
        var selctedItem = dijit.byId('dynamiceventgridCWPROCESSEVENTLOG').selection.getSelected();
        if(selctedItem.length){
            //alert("grid row selected");
            dojo.forEach(selctedItem, function(selectedItem){
            if(selectedItem !== null){
                dojo.forEach(dijit.byId('dynamiceventgridCWPROCESSEVENTLOG').store.getAttributes(selectedItem), function(attribute){
                    var value = dijit.byId('dynamiceventgridCWPROCESSEVENTLOG').store.getValues(selectedItem, attribute);
                });
            }
            var objectId = document.getElementById("CWPROCESSEVENTLOG.OBJECT_ID").value;
            if(objectId != ""){
                //alert(objectId);
                popupWindowWithPost("processManager.jsp",'height=600px,width=960px,top=50px,left=150px,scrollbars=no,sizable=yes,toolbar=no,statusbar=no','processManagerpopup',objectId);  
            }else{
                alert("Please have some value in Process ID field");
            }
            });
        }else{
            alert("grid loaded and row nt selected");
        }
    }
    if(gbshowgridFlag==false){
        alert("grid not loaded");
    }
}
<script type="text/javascript">
function foo(){
     window.buttonid=document.getElementById('button1');
     window.open("childwindow.html","child window");
}
</script>
<body>
<!-- some stuff here -->
<button id="button1" name="NiceButton" onclick="foo()">click here</button>
</body>
<script type="text/javascript">
function loading(){
    alert(window.opener.buttonid.name);
}
</script>
<body onload="loading();"></body>