开发者

Copy-pasting root-relative URLs in a contenteditable region

Here's the test: http://jsfiddle.net/chrisdarroch/FVd4p/

The goal is to be able copy and paste the image (whose src attribute has a root-relative URL -- /images/logo.png) so that the pasted image also has a root-relative URL.

Right now, here's how the different browsers seem to cope:

  • In IE8, the pasted image's src will be a root-relative URL.
  • In Google Chrome, it will be an absolute URL.
  • In Firefox 3.6, it will be just a relative URL.

So Firefox is the problem here. You'll note that when the is pasted in to the document, the element's src attribute doesn't have the /开发者_运维知识库 prefix on the URL any more (so it's relative to the page rather than the root of the site), but it somehow manages to divine what the correct relative URL should be.

Is this a case of Firefox trying to be too intelligent and failing? How could I adjust the src attribute on paste so that Firefox will play nice and insert a root-relative URL?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜