Getting current URL in Flash from JavaScript using ExternalInterface and IE

前端 未结 4 1999
情歌与酒
情歌与酒 2021-01-15 13:54

I\'m trying to get the current URL that the Flash player is on. Not the URL of the .swf file, but the URL that the browser is pointing to. Thus far I\'ve used:



        
4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-15 14:46

    You need a couple of things in order to make it work in IE. First the ActionScript:

    var domain:String = ExternalInterface.call('function () { return window.location.href; }');
    

    Second, you need valid classid and id atributes in the tag:

    
    
    
    

    If you don't put those attributes, ExternalInterface.call always returns null in IE6/7/8 but works as expected in firefox.

    Third, you need to set the param allowScriptAccess to 'always', in order to enable the use of ExternalInterface.

    
    ..
    
    

    .....

    提交回复
    热议问题