PDA

View Full Version : Javascript within DHTML window



napesjp
05-17-2010, 05:22 PM
1) Script Title: DHTML Window widget (v1.1)

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/index.htm

3) Describe problem:
I am trying to run some javascript calls on an html form within an ajax content window (window 3). It does not seem to be working properly. Is there a special way to reference object ids or function calls within the window that I'm missing?

for example, the following does not work inside the modal window:

<script type="text/javascript">
function myFunction(id) {
document.getElementById( id ).style.background="DBDBDB"}
</script>

...

<input type="text" name="foo" id="foo" onClick="myFunction('foo');">

ddadmin
05-18-2010, 08:31 AM
Ah this isn't an issue with the script, but rather, just a pesky limitation of Ajax. Pages fetched via Ajax should they contain JavaScripts within it in many cases won't run correctly when brought over this way. Ajax basically copies the contents of the external file similar to copying plain text and just dumps it onto the main page. Browsers don't know to interpret scripts or even CSS (in IE) within that copied content.

The easy solution in this case is just to switch to the IFRAME version when showing pages within JavaScript in it inside the DHTML window.

napesjp
05-18-2010, 02:10 PM
That did it, thanks!