开发者

Problems with Prototypes replace()-method in IE

I'm using the .replace()-Method to replace HTML content. I need the previous element that gets replaced so I'm using the return value of this function. In IE8 this returns an empty string in a specific case (I can't provide an example, because the script is not standalone).

I did some research and found out that IE8 calls Element.Method开发者_高级运维s.replace in line 2770 (Prototype 1.7), where Mozilla does call "replace" in line 2059.

Element.Methods.replace does some stuff and finally replaces the original elements outerHTML with the new content which gets stripped somehow (line 2791).

Finally it seems to me it returns the orginal element that should be replaced, but already modified with the new content in line 2791, where it becomes an empty string.

So I basically have two questions:

  1. To dig a little bit further why this happens, can someone explain when exactly this method is called? IE doesn't seem to fire it on every replace() call.

  2. It seems wrong to me that this function returns the modified original element instead of just returning the original element. Is this expected behaviour here?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜