Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by junho on Feb 16, 2009 22:44
open dhtmlx forum
problem on using dhtmlxWindows

hi there.

im using dhtmlxWindows for popup contents.
the contens attached by attachURL().

i can not access 'parent' object when contents submited.

what is the problem on below?

can anyone help?

ps. i am not a native speaker of English. but i hope you can understand my message :)

parent.asp
=================================
<script language="javascript">
var dhxWins = new dhtmlXWindows();
dhxWins.setImagePath("/Common/DHTMLXSuite/codebase/imgs/");
dhxWins.enableAutoViewport(true);

/******************************
Create dhtmlxWindow
******************************/
function newWin(){
    var f = document.crsFrm;
    var queryString = formData2QueryString(f); // parsing form-date to querystring
    var strURL = ?" + queryString;
    
    // create newdhtmlxWindows
    var win1 = dhxWins.createWindow("w1", 0, 0, 490, 450);
    
    win1.button("minmax1").hide();
    win1.button("minmax2").hide();
    win1.button("park").hide();
    
    win1.denyResize();
    win1.center();    
    win1.setModal(true);
    
    win1.setText("win1");
    
    win1.attachURL("form.asp");
}
</script>
=================================


form.asp
=================================
<html>
<body>
    <form name="form1" method="post" action="action.asp">
        <input type="text" name="text1" value="">
        <input type="submit" value="submit">
        <input type="button" value="close" onclick="parent.dhxWins.('w1').close();"> // <-- this script works
    </form>
</body>
</html>
=================================


action.asp
=================================
'
'
some ASP codes..
'
'

<script language="javascript">
alert("process complete");
parent.dhxWins.('w1').close(); // <-- error. parent object is undefined
</script>
=================================
Answer posted by Alex (support) on Feb 17, 2009 09:19

Hi,

Please try to use the following code at the action.asp page to close win1 window:

<script>
parent.win1.close();
</script>

Answer posted by junho on Feb 17, 2009 17:28

thanks for advice.

but it still throw error 'undefined' is null or not an object.

//parent.dhxWins.window("w1").close();
parent.win1.close(); // <-- error : 'undefined' is null or not an object.

i'm using IE7.

Answer posted by Support on Feb 18, 2009 09:12
You are using
function newWin(){ 
  ...
  var win1 = dhxWins.createWindow("w1", 0, 0, 490, 450);

As result var win1 visible only from context of that function, and not visible for any other code ( good approach in common place, but cause problems for you calls from iframe)
To resolve issue just define it on global level. 

var win1;
function newWin(){ 
  ...
  win1 = dhxWins.createWindow("w1", 0, 0, 490, 450);