0

背景画像の「スタイル」属性を持つ div があります。次のものが引き戻されます。

background-image: url("<img alt="" src="/mysite/imagegallery/PublishingImages/Gallery/image.png" style="BORDER&#58;0px solid;" />"); background-attachment: scroll; background-repeat: no-repeat; background-position-x: 0%; background-position-y: 0%; background-color: transparent;

以下を削除したいと思います

/mysite/imagegallery/Images/Gallery/image.png

これができたら、JS を記述してスタイル属性を置き換えることができます。

どんな助けでも大歓迎です。

4

2 に答える 2

0

CMS で問題を修正する必要があります。しかし、あなたの質問に答えるために、これを行うことができます。

HTML

<div id="screwedByCMS" style='background-image: url("<img alt="" src="/mysite/imagegallery/PublishingImages/Gallery/image.png" style="BORDER&#58;0px solid;" />"); background-attachment: scroll; background-repeat: no-repeat; background-position-x: 0%; background-position-y: 0%; background-color: transparent;'></div>

Javascript

var screwedByCMS = document.getElementById("screwedByCMS"),
    imageURL = screwedByCMS.attributes.style.nodeValue.match(/src="(\S+?)"/);

console.log(imageURL[1]);

戻り値

/mysite/imagegallery/PublishingImages/Gallery/image.png 

jsfiddleについて

于 2013-06-12T15:07:33.847 に答える
-2

正規表現を使用できます

var matches = '<img alt="" src="..."'.match(new RegExp("src=\"([a-zA-Z0-9/.]+)\""));
var srcString = matches[1];
于 2013-06-12T14:50:50.240 に答える