开发者

How is it possible to dynamically change the flash file using swfobject through javascript

开发者 https://www.devze.com 2022-12-21 22:52 出处:网络
I\'m looking to dynamically change the flash files based f开发者_高级运维rom an hyperlink on the page without the page having to reloading. Is this possible through javascript?Yes, it\'s possible. See

I'm looking to dynamically change the flash files based f开发者_高级运维rom an hyperlink on the page without the page having to reloading. Is this possible through javascript?


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


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">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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号