# Passing JavaScript function in an XML file to Flash

**URL:** <https://forum.kirupa.com/t/passing-javascript-function-in-an-xml-file-to-flash/154306>\
**Category:** flash\
**Created:** [July 8, 2005, 1:24pm UTC](https://forum.kirupa.com/t/passing-javascript-function-in-an-xml-file-to-flash/154306 "2005-07-08T13:24:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryanmac79](https://avatars.discourse-cdn.com/v4/letter/r/cab0a1/32.png) [@ryanmac79](https://forum.kirupa.com/u/ryanmac79)\
**Post date:** [July 8, 2005, 1:24pm UTC](https://forum.kirupa.com/t/passing-javascript-function-in-an-xml-file-to-flash/154306/1 "2005-07-08T13:24:21Z")

</div>

After looking around for an answer I’ve found two ways that sound like they should work, but don’t yet, for me anyway:

Trying to get an HTML link from an XML file to open in a custom browser window. Dynamic HTML enabled text box getting data from the XML file. At some point I think it needs to call a JavaScript function to open the custom window. I have gotten this to work using [CDATA[asfunction:getURL… (in the XML file) but not once I call for the JavaScript. Here’s what I figured out:

I think it can be done using either CDATA in the XML file. Something like this for the XML in your example  
…

```auto

<portfolio>
<pictures><![CDATA[<thumb><a href="asfunction:getURL,javascript:openNewWindow('http://www.thelink.com','thewin','height=250,width=300,toolbar=no,scrollbars=yes')">Text to link</a></thumb>]]></pictures>
</portfolio>

```

…

or maybe it calls the function in the ActionScript when when you are getting the data for the dynamic text box:

…

[AS]  
output += “\<p\>\<a href=“javascript:openNewWin(” + d[c].attributes.thumb + “)” target=”\_blank"\>" + d[c].firstChild.nodeValue + “\</a\>\</p\>”;  
[/AS]

…

Either one is supposed to call a JavaScript function that is in the head of the HTML file the embedded .swf file is on.

I’m not really sure what I’m missing. Everything else works but I can’t get it to call those functions. Anybody that’s done this successfully? Thanks all!
