页面调用flash文件之路径问题(IE)
Posted by wengjian on January 4th, 2009 filed in web前端技术今天发现一个很诡异的问题 :
页面调用一个swf文件(该文件在kecheng.example.net/courses 这个目录下),该swf文件内部as调用其他的swf文件(文件在其他的域名目录下,跟页面调用的那个swf文件不在同目录下),在ie下 第一次可以调用 刷新后无法调用。
(页面地址:http://kecheng.example.net/courses/flash_s/4)
调用代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 | function show_flash(swf_url) { var so = new SWFObject(swf_url,'aa','710','532','8','#ffffff'); so.addParam('allowscriptaccess','always'); so.addParam('wmode','transparent'); var base_url = swf_url.replace(/\/[^/]*$/, '/') so.addParam('base', base_url); so.addParam('allowfullscreen','true'); so.addVariable('width','710'); so.addVariable('height','532'); so.write('flash_viewer'); } show_flash(''); |
查询adobe网站查到 有base这个属性 (官网地址)
base - . or [base directory] or [URL]. Specifies the base directory or URL used to resolve all relative path statements in the Flash Player movie. This attribute is helpful when your Flash Player movies are kept in a different directory from your other files.
这个属性可以指定as调用swf文件的相对路径的路径基准.
例如: a.swf文件处于 www.aa.com/kecheng 下,b1.swf、b2.swf 2个文件处于www.bb.com/kecheng 下其中b1.swf文件as代码调用b2.swf文件 。在www.aa.com/kecheng下的a.swf文件调用b1.swf文件 ,如果不加base这个属性的话 b1.swf是调用不到b2.swf这个文件的(因为b2.swf文件的路径已经变成www.aa.com/kecheng 了) 加上属性 就可以指定其相对路径的基准是www.bb.com/kecheng 这样就可以调用到b2.swf文件了。
但是在IE6.7下刷新页面后b2.swf文件就调用不到了 使用iewatch 发现页面刷新后b2.swf的路径已经变成www.aa.com/kecheng了,base属性在ie下失效了,但是删除ie临时文件又可以了,然后刷新又不可以了。
通过iewatch 观察后,发现可能是ie缓存的问题 ,就在调用地址上加了上一个随机数字
1 | show_flash('?'+ Math.random()); |
问题解决。
此问题非常诡异,虽然解决了,但是更深层次的原因还是没弄明白,望哪位高手解释下!
No related posts.
September 7th, 2010 at 10:03 PM
Buy:Benicar.SleepWell.Prozac.Lipothin.Lipitor.Female Pink Viagra.Nymphomax.Buspar.Aricept.Lasix.Zocor.Wellbutrin SR.Ventolin.Amoxicillin.Cozaar.Zetia.Advair.Acomplia.Female Cialis.Seroquel….
November 11th, 2010 at 12:53 PM
…
BUY FASHION. TOP BRANDS: GUCCI, DOLCE&GABBANA, BURBERRY, DIESEL, ICEBERG, ROBERTO CAVALLI, EMPORIO ARMANI, VERSACE…