Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Rob Gwyther on Sep 21, 2009 04:01
open dhtmlx forum
Unable to Run Java Script in DHTMLX Window after attachURL

I'm having a problem running some java script after attaching a basic HTML page to a DHTMLX Window. All I really want todo is call some javascript in order to pass in some values.

I've scoured the knowledge base and documentation but to no avail! I can't see what i'm doing differnetly from what the documentation says!

All I get is an error saying that either the method doesn't exist on that object or that the object is null or not an object.

A cut down version of my source code is below.

Many thanks,

Rob

// Window Call Code---------------------------------------------------------------------------

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Attach Win</title>

<link rel="stylesheet" type="text/css" href="./DHTMLXSuite/dhtmlxWindows/codebase/dhtmlxwindows.css">
<link rel="stylesheet" type="text/css" href="./DHTMLXSuite/dhtmlxWindows/codebase/skins/dhtmlxwindows_dhx_skyblue.css">

<script src="./DHTMLXSuite/dhtmlxWindows/codebase/dhtmlxcommon.js"></script>
<script src="./DHTMLXSuite/dhtmlxWindows/codebase/dhtmlxwindows.js"></script>
<script src="./DHTMLXSuite/dhtmlxAccordion/codebase/dhtmlxcontainer.js" type="text/javascript" charset="utf-8"></script>

</head>
<body onload="doOnLoad()">
<div id="winVP" style="position: relative; height: 500px; border: #cecece 1px solid; margin: 10px;"></div>
</body>
<script>
var dhxWins;
function doOnLoad() {
dhxWins = new dhtmlXWindows();
dhxWins.enableAutoViewport(false);
dhxWins.attachViewportTo("winVP");
dhxWins.setImagePath("./DHTMLXSuite/dhtmlxWindows/codebase/imgs/");
win = dhxWins.createWindow("win_disc",200, 200, 200, 200);
dhxWins.window("win_disc").attachURL("./basic.html", true);
dhxWins.window('win_disc')._frame.contentWindow.MyFunc("Hello!");

}
</script>
</html>

----------------------------------------------------------------------------------------------

// Basic HTML Code ----------------------------------------------------------------------

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Basic Win</title>
<script>
function MyFunc(txtVal)
{
    alert(txtVal);
}
</script>

</head>
<body>
Basic Window
</body>
</html>
------------------------------------------------------------------------------------------------------
Answer posted by Alex (support) on Sep 21, 2009 08:54

method attachURL(url,true) loads content by Ajax (asynchronously) and iframe isn't used in this case:

dhxWins.window('win_disc').attachEvent("onContentLoaded",function(win){

window.setTimeout(function(){MyFunc("Hello!");},1); 

});

dhxWins.window("win_disc").attachURL("./basic.html", true); 

We have attached the version of dhtmlxcontainer.js that executes script defined in the attached page.



Attachments (1)