IE不会从Ajax响应中删除Flash Object src [英] IE not retreving Flash Object src from Ajax response

查看:291
本文介绍了IE不会从Ajax响应中删除Flash Object src的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图读取flash文件的src属性,然后通过swfobject创建一个新文件。但是,当我读取嵌入标签的src时,它返回未定义。我的代码如下。



我正在做一个帖子的页面,只有Flash文件。



回应如下:

AJAX REsponse



 < object classid =clsid:D27CDB6E-AE6D-11cf-96B8-444553540000codebase =http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0 width =930height =630title =Campaign> 
< param name =movievalue =final5.swf/>
< param name =qualityvalue =high/>
< / object>






脚本



  $。ajax({
url:flashUrl,
type:POST,
dataType:html,
成功:function(data,status,xhr){
var swfUrl = flashUrl.substr(0,flashUrl.lastIndexOf('/'))+/+ $(data).find('embed' ).attr('src');
$('。content')。html('< div id =mySwf>< / div>);
swfobject.embedSWF swfUrl,mySwf,200,200,9.0.0,/resources/expressInstall.swf,flashvars,属性,参数);

}
} );






* * *更新(发现问题区域,但不是解决方案)



我有点知道问题是什么,但是我不知道它发生了什么。
当我运行在IE浏览器中的Flash文件页面。它以一种奇怪的方式渲染它

 < object width =930height =630title =Campaignclassid =clsid:D27CDB6E-AE6D-11cf-96B8-444553540000codeBase =http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0altHtml =

< embed src =skf-final5.swftype =application / x-shockwave-flashwidth =930height =630quality =highpluginspage = http://www.macromedia.com/go/getflashplayer>< / embed>
>

它会将一些 altHTML 属性添加到Object,整个嵌入标签进入它拧起来的东西。 :

解决方案

解决这个问题。




继承我的解决方案。(请建议是否有任何改进)


$ b $

  $。ajax({
url:flashUrl,
type:POST,
dataType: html,
成功:function(data,status,xhr){
$('。layer-view .content')。html('< div id =kcSwf>< div>');
//构建flash url的路径
var swfUrl = flashUrl.substr(0,flashUrl.lastIndexOf('/'))+/+ $(data).findAndSelf attr('value');
var swfWidth = $(data).findAndSelf('object')。attr('width');
var ('''');
var swfBgColor = $(data).findAndSelf('param [name =bgcolor]')。attr('值');

if(swfBgColor ==undefined)sw fBgColor =#ffffff;

var layerviewWidth = parseInt(swfWidth)+ 20;
$('。layer-view .view')。css('width',layerviewWidth);

var flashvars = false;
var params = {salign:'t',bgcolor:swfBgColor};
var attributes = {};
swfobject.embedSWF(swfUrl,kcSwf,swfWidth,swfHeight,flashVersion,/resources/expressInstall.swf,flashvars,params,attributes);
}
});

注意:FYI .... swfobject中属性的顺序也很重要。 Param必须在属性之前来到,否则就会在IE中产生一些东西。 :)

I am trying to read the src attribute of the flash file which i get in the response of a url and create a new file through swfobject. But it returns me "undefined" when i read the src of the embed tag. My code below.

The page i am doing a post on, only has the flash file in it.

The reponse is as below:

AJAX REsponse

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"     codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="930" height="630" title="Campaign">
  <param name="movie" value="final5.swf" />
  <param name="quality" value="high" />
  <embed src="final5.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="930" height="630"></embed>
</object>


Script

$.ajax({
 url: flashUrl,
 type: "POST",
 dataType:"html",
 success: function(data, status, xhr) {
   var swfUrl = flashUrl.substr(0, flashUrl.lastIndexOf('/')) + "/" + $(data).find('embed').attr('src'); 
   $('.content').html('<div id="mySwf"></div>');
   swfobject.embedSWF(swfUrl, "mySwf", "200", "200", '9.0.0', "/resources/expressInstall.swf", flashvars, attributes, params);

  }
});


***Update (found the issue area but not the solution)

I kinda got to know what the issue is, but i don't know y its occurring. when i run the page with the flash file in IE. it renderes it in a wierd way

<object width="930" height="630" title="Campaign" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codeBase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" altHtml="     

 <embed src="skf-final5.swf" type="application/x-shockwave-flash" width="930" height="630" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" >    </embed>
     ">

it add some altHTML attribute to the Object and the entire embed tag goes into it which screws up the entire stuff. :(

解决方案

Well dint find the reason y we get a "altHTML" in the tag. but found a work around for this problem.


Heres my solution. (please suggest if there can be any improvements)

$.ajax({
url: flashUrl,
type: "POST",
dataType:"html",
success: function(data, status, xhr) {
    $('.layer-view .content').html('<div id="kcSwf"></div>');
                        // Building path for flash url
    var swfUrl = flashUrl.substr(0, flashUrl.lastIndexOf('/')) + "/" + $(data).findAndSelf('param[name="movie"]').attr('value'); 
    var swfWidth = $(data).findAndSelf('object').attr('width'); 
    var swfHeight = $(data).findAndSelf('object').attr('height'); 
    var swfBgColor = $(data).findAndSelf('param[name="bgcolor"]').attr('value');

    if(swfBgColor=="undefined") swfBgColor="#ffffff";

        var layerviewWidth = parseInt(swfWidth) + 20; 
        $('.layer-view .view').css('width', layerviewWidth);

        var flashvars = false;
        var params = {salign:'t', bgcolor:swfBgColor};
        var attributes = {};
        swfobject.embedSWF(swfUrl, "kcSwf", swfWidth, swfHeight, flashVersion, "/resources/expressInstall.swf", flashvars, params, attributes);
    }
});

Note: FYI....The sequence of the properties in swfobject is also important. The Param has to come before the attribute or else it screws up some stuff in IE. :)

这篇关于IE不会从Ajax响应中删除Flash Object src的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆