Update flashvars value via JS/jQuery in embed object

114 Views Asked by At

I have this code:

 <embed src="http://mydomain/s/b.swf"
               quality="high"
               id="test"
               bgcolor="#ffffff"
               width="550"
               height="400"
               name="myFlashMovie" flashvars="Parameter1=3z3krkvhg0w3m0uhizp4wfdt98832&Parameter2=0"
               align="middle"
               allowscriptaccess="sameDomain"
               allowfullscreen="false"
               type="application/x-shockwave-flash"
               pluginspage="http://www.adobe.com/go/getflash" />

I'm trying to set the flashvars value via either jQuery or pure JS but I can't set them on document ready, is it possible to edit that value at all?

I'm able to access the object per the console but can't edit the value.

   <script type="text/javascript">
    jQuery(document).ready(function () {
        console.log(getUrlParameter('Parameter1'));
        console.log(getUrlParameter('Parameter2'));
        var valueToShare = getUrlParameter('Parameter1') + getUrlParameter('Parameter2');
        $('#test').find('embed').attr('FlashVars', 'adasdasda');
        console.log($('#test').attr('FlashVars'));
        function getUrlParameter(sParam) {
            var sPageURL = decodeURIComponent(window.location.search.substring(1)),
                sURLVariables = sPageURL.split('&'),
                sParameterName,
                i;

            for (i = 0; i < sURLVariables.length; i++) {
                sParameterName = sURLVariables[i].split('=');

                if (sParameterName[0] === sParam) {
                    return sParameterName[1] === undefined ? true : sParameterName[1];
                }
            }
        };
    });
</script>
0

There are 0 best solutions below