开发者

send parameters from the javascript tag to javascript file

Is it possible?, for example:

<script type="text/javascript">google.load("swfobject","2.2")</script>
<script type="text/javascript" src="js/myswf.js?swf=animate01"></script>

in the myswf.js file :

swfobject.embedSWF("flash/"+swf+".swf","ID","258","371开发者_运维问答","9.0.0","",{},wmode:"transparent"},{});

Is it possible to do something like this? thanks in advance :)


Short answer is yes, but you would need to create a separate JavaScript file to parse all your elements and look for those parameters.

For what it looks like you're trying to do there's a most likely a simpler solution.

edit:

Here's some code:

<script type="text/javascript">
  function doEmbed(name) {
    swfobject.embedSWF("flash/"+name+".swf","ID","258","371","9.0.0","",{},wmode:"transparent"},{});
  }

  doEmbed("animate01");
</script>


You could register a global var called swf in the first script. References to a varaible called swf in javascript interpreted after will reference this object as its global. Its not a good practice to do this but it works. I would rather all my code working with that variable be in one place :) That way i avoid dangerous side effects and ugly globals littering my javascript...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜