私はoembedによって吐き出されるコードのブロックを持っています。 iframeのsrc属性を対象にして、data-src
に置き換える必要があります。ターゲットiframe src内のajax_injectedチャンク
彼女は、私が現在持っているものだ:コードの塊内部src
あまりにも多くの変更の上)
embed_request = {
url: url,
dataType: "jsonp",
cache: false,
success: function (data) {
try {
var embed_html = (data.html).replace('src', 'data-src');
$("div#item"+number).html(embed_html);
} catch (err) {
console.log(err);
}
}
};
$.ajax(embed_request);
問題は、私が(交換することであるData.HTMLに
私はjavascriptやjqueryのを経由して伝えることができますどのようにここvar embed_html = (data.html).replace('src', 'data-src');
はiframeのsrcをhtmlコードのチャンクの内側に変更するだけです。
今日、残念ながら私の現在のコードは以下のiframe SRCもsrc="//platform.instagram.com/en_US/embeds.js"
のSRCないだけを変更します。
<iframe src="https://www.instagram.com/p/64567SDFFDFS/embed/captioned/?cr=1&v=7" class="instagram-media instagram-media-rendered" id="instagram-embed-0" allowtransparency="true" frameborder="0" height="849" data-instgrm-payload-id="instagram-media-payload-0" scrolling="no" style="border: 1px solid rgb(219, 219, 219);"></iframe>
<script async="" defer="" src="//platform.instagram.com/en_US/embeds.js"></script>
だから私は、最終的なスピッティングビューで取得する:
<iframe data-src="https://www.instagram.com/p/64567SDFFDFS/embed/captioned/?cr=1&v=7" class="instagram-media instagram-media-rendered" id="instagram-embed-0" allowtransparency="true" frameborder="0" height="849" data-instgrm-payload-id="instagram-media-payload-0" scrolling="no" style="border: 1px solid rgb(219, 219, 219);"></iframe>
<script async="" defer="" data-src="//platform.instagram.com/en_US/embeds.js"></script>
のみターゲットにする方法iframeのsrc?
おかげ
EDITここ
は
<div class="item " id="item2">
<div id="fb-root" class=" fb_reset"><div style="position: absolute; top: -10000px; height: 0px; width: 0px;"><div></div></div><div style="position: absolute; top: -10000px; height: 0px; width: 0px;"><div><iframe name="fb_xdm_frame_http" frameborder="0" allowtransparency="true" allowfullscreen="true" scrolling="no" title="Facebook Cross Domain Communication Frame" aria-hidden="true" tabindex="-1" id="fb_xdm_frame_http" src="http://staticxx.facebook.com/connect/xd_arbiter/r/0eWevUAMuoH.js?version=42#channel=f3e391184&origin=http%3A%2F%2Flocalhost%3A3000" style="border: none;"></iframe><iframe name="fb_xdm_frame_https" frameborder="0" allowtransparency="true" allowfullscreen="true" scrolling="no" title="Facebook Cross Domain Communication Frame" aria-hidden="true" tabindex="-1" id="fb_xdm_frame_https" src="https://staticxx.facebook.com/connect/xd_arbiter/r/0eWevUAMuoH.js?version=42#channel=f3e391184&origin=http%3A%2F%2Flocalhost%3A3000" style="border: none;"></iframe></div></div></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/fr_FR/sdk.js#xfbml=1&version=v2.3";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script><div class="fb-post fb_iframe_widget" data-href="https://www.facebook.com/cocacolafrance/posts/1526674334016658" data-width="536" fb-xfbml-state="rendered" fb-iframe-plugin-query="app_id=&container_width=0&href=https%3A%2F%2Fwww.facebook.com%2Fcocacolafrance%2Fposts%2F1526674334016658&locale=fr_FR&sdk=joey&width=536"><span style="vertical-align: bottom; width: 536px; height: 404px;"><iframe name="f2115553f8" width="536px" height="1000px" frameborder="0" allowtransparency="true" allowfullscreen="true" scrolling="no" title="fb:post Facebook Social Plugin" src="https://www.facebook.com/v2.3/plugins/post.php?app_id=&channel=http%3A%2F%2Fstaticxx.facebook.com%2Fconnect%2Fxd_arbiter%2Fr%2F0eWevUAMuoH.js%3Fversion%3D42%23cb%3Dfc155ce24%26domain%3Dlocalhost%26origin%3Dhttp%253A%252F%252Flocalhost%253A3000%252Ff3e391184%26relation%3Dparent.parent&container_width=0&href=https%3A%2F%2Fwww.facebook.com%2Fcocacolafrance%2Fposts%2F1526674334016658&locale=fr_FR&sdk=joey&width=536" class="" style="border: none; visibility: visible; width: 536px; height: 404px;"></iframe></span></div></div>
Facebookの
のoEmbed
Instagramの
<div class="item active" id="item1">
<iframe class="instagram-media instagram-media-rendered" id="instagram-embed-0" src="https://www.instagram.com/p/BPodiIYgG3K/embed/captioned/?cr=1&v=7" allowtransparency="true" frameborder="0" height="776" data-instgrm-payload-id="instagram-media-payload-0" scrolling="no" style="border: 1px solid rgb(219, 219, 219); margin: 1px 1px 12px; max-width: 320px; width: calc(100% - 2px); border-radius: 4px; box-shadow: none; display: block; padding: 0px; background: rgb(255, 255, 255);"></iframe>
<script async="" defer="" src="//platform.instagram.com/en_US/embeds.js"></script>
</div>
によってスピッティングHTMLチャンクコードの2つの例です
'(Data.HTMLに).find( 'IFRAME')( 'SRC' を置換します、 'data-src'); '? – Nope
多分ここを見てください:http://stackoverflow.com/questions/40761222/wants-to-replace-the-iframe-based-on-onlclick/40761290#40761290 –
@M.Be inesems彼らはIDを介してそれをターゲットにしていますが、私は私のコードベースにIDを持っていない。私はajax経由でhtmlを投げつけるoembedコードしか持っていません。だから私はあらかじめわからないIDをターゲットにしていません。 – Mathieu