“无效参数”在IE 8上的jQuery.prepend()Flash对象 [英] "Invalid argument" in IE 8 on jQuery.prepend() on flash objects

查看:171
本文介绍了“无效参数”在IE 8上的jQuery.prepend()Flash对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

演示页面

运行在IE 8中,这段代码会产生一个无效参数的异常。作为描述和消息,这个数字: -2147024809

When run in IE 8, this code yields an exception with "Invalid argument." as description and message, and this number: -2147024809

我正在使用最新的(1.7.1)jQuery 。这是一个已知的错误?如何解决?

I'm using latest (1.7.1) jQuery. Is this a known bug? How to resolve?

var objs=$('object').not('object param[name="wmode"][value="transparent"]');
var appended = $('<param name="wmode" value="transparent"></param>');
objs.prepend(appended);

Html片段:

Html snippet:

<object width="Width in Pixels" height="Height in Pixels" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0">
  <param name="salign" value="lt">
  <param name="quality" value="high">
  <param name="scale" value="noscale">

  <param name="movie" value="http://geekfile.googlepages.com/flvplay.swf">
  <param name="FlashVars" value="&streamName=FLV_Video_URL&skinName=http://geekfile.googlepages.com/flvskin&autoPlay=true&autoRewind=true">
  <embed width="Width in Pixels" height="Height in Pixels" flashvars="&streamName=FLV_Video_URL&autoPlay=true&autoRewind=true&skinName=http://geekfile.googlepages.com/flvskin" quality="high" scale="noscale" salign="LT" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" src="http://geekfile.googlepages.com/flvplay.swf" wmode="transparent">
  </embed>
</object>

jquery.js第5771行发生错误:

The error occurs on jquery.js line 5771:

this.insertBefore( elem, this.firstChild );

更新:这不是一个jQuery问题原始的JavaScript。

Update: This is not "a jQuery issue" - it happens with raw javascript.

这段代码抛出: / p>

This code throws:

function handle(object) {
  var html = object.innerHTML;

  // The following line throws an exception:
  // Also, 'html' is not empty or undefined at this point.
  object.innerHTML = '<param name="wmode" value="transparent"></param>' + html;  
}


推荐答案

确定这是我的头顶,但遇到过这样的事情,这是特定于< object> 标记。 IE浏览器没有看到这个作为HTML DOM的一部分,所以用jQuery处理返回一个空对象。我记得工作的解决方案是html5shiv like,创建一个对象元素,并将param作为一个字符串,而不是一个jQuery对象,所有应该是好的。

I'm not 100% sure about this off the top of my head, but encountered something like this before, and it was specific to the <object> tag. IE does not see this as part of the html dom, so manipulation with jquery returns a null object. The solution I remember working was html5shiv like, create an object element and append the param as a string instead of a jQuery object and all should be well.

另外,你可以将Flash包装在一个div中,然后得到该div的内部html,附加到该html,然后将其放回到包装div中。

Alternatively, you could wrap the flash in a div, then get that div's inner html, append to that html, then drop it back into the wrapper div.

这篇关于“无效参数”在IE 8上的jQuery.prepend()Flash对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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