views:

111

answers:

2

I'm looking to dynamically change the flash files based from an hyperlink on the page without the page having to reloading. Is this possible through javascript?

A: 

Do you mean you want to change the destination of a hyperlink on the page through javascript? Something like this should do that:

<body>
    <a id="test" href="http://www.google.com"&gt;Go to Google</a>
    <input type="button" onclick="document.getElementById('test').href = 'http://www.yahoo.com'" value="Go to Yahoo"/>
</body>

Or are you trying to do something different? Like changing what Flash is displayed by clicking a hyperlink? Haven't tried it, but the above approach might work there, too, with a little tweaking. Remember that the attributes of an element (like the href above) are available in javascript as properties once you have a reference to the element, so you should be able to change whatever attribute of the element you need to.

Ryan Mitchell
A: 

Yes, it's possible. See this tutorial: http://learnswfobject.com/advanced-topics/load-a-swf-using-javascript-onclick-event/

pipwerks
Awesome, exactly what I was looking for.
craig