我有一个CMS系统,我可以选择管理广告。现在我所拥有的是一个文本框,其中粘贴了他们的代码,我希望快速显示广告,以便他们可以看到广告以及它是否正常工作。问题就在这里:problem to display dynamically a javascript google ad in an iframe using jquery(阅读第一个答案)。
我想知道是否有可能做到这一点,或者唯一的选择是他们只能粘贴代码,但不会从CMS本身看到它。
修改 我正在添加代码:
<div class="block" data="500" style="margin-top: 5px; height: 644px;">
<span class="brow" style="float: right;"><span class="label pla">תצוגה מקדימה:</span><div class="dprev"></div></span>
<span class="brow" style="float: left; margin-top: 0;"><span class="label">הקוד:</span><br />
<form action="pages/ad.php" target="preview1" method="post">
<textarea data="1" name="textbox" class="dcode" style="float: none; resize: none; width: 312px; height: 543px;">
<div style="width:160px;border:solid 1px #E5E5E5">
<INPUT id="merlin_q3" type="hidden" value="1">
<SCRIPT type=text/javascript>
function fnMerlinAddUrl(qStr,val) {
try{return('&' + qStr + '=' + val)}
catch(e){}
}
//params
merlin_partnerid = "3541";
merlin_search="q3";
merlin_search_result= '6';
merlin_start_offset= 0;
merlin_cols = '1';
merlin_lang="heb";
merlin_width ="90%";
merlin_url = "" ;
merlin_AdType="short_title_heb";
merlin_Iframe_Unique_Index="3";
merlin_default = "1";
merlin_decodeKeyword = escape(document.getElementById("merlin_q3").value);
var path='http://www.merlin.co.il/merlin_3rdparty/merlin_3rdparty.asp'; //&all=news
merlin_url=path+"?utf=0&fixed=marimedia&modaa=mo"+fnMerlinAddUrl("partnerid",merlin_partnerid);
merlin_url+=fnMerlinAddUrl("lang",merlin_lang);
merlin_url+=fnMerlinAddUrl("AdType",merlin_AdType);
merlin_url+=fnMerlinAddUrl("qtyResult",merlin_search_result);
merlin_url+=fnMerlinAddUrl("ScriptIndex",merlin_Iframe_Unique_Index);
merlin_url+=fnMerlinAddUrl("start_offset",merlin_start_offset);
merlin_url+=fnMerlinAddUrl("cols",merlin_cols);
merlin_url+=fnMerlinAddUrl("merlin_default",merlin_default);
merlin_url+='&q=' +merlin_decodeKeyword;
merlin_url+='&urlTag='+ "http%3A%2F%2Ftracking.merlin.co.il%2Faff_c%3Foffer_id%3D58%26aff_id%3D1216%26file_id%3D1652";
document.write("<table width=100%><tr><td valign=top id='Merlin_tdInsert3'></td></tr></table>");
var MerlinSS_OBJ=document.getElementsByTagName("HEAD");
if(!MerlinSS_OBJ)document.createElement('HEAD');
var oScript= document.createElement("script");
oScript.setAttribute("src",merlin_url);
document.getElementsByTagName("HEAD")[0].appendChild(oScript);
</SCRIPT>
</div><img src="http://tracking.merlin.co.il/aff_i?offer_id=58&aff_id=1216&file_id=1652" width="1" height="1">
</textarea>
</form></span>
<button style="position: absolute; margin-right: 330px; bottom: 14px;"><img src="img/v.png" style="margin-top: -2px; margin-left: 2px;" alt="add" height="28"/>שמור שינויים</button>
</div>
<h1 style="margin-top: -45px; position: relative;right: 574px;">פרסומת 2:</h1>
<div class="block" data="500" style="margin-right: 45px; height: 644px; margin-top: 5px;">
<span class="brow" style="float: right;"><span class="label pla">תצוגה מקדימה:</span><div class="dprev"></div></span>
<span class="brow" style="float: left; margin-top: 0;"><span class="label">הקוד:</span><br />
<form action="pages/ad.php" target="preview2" method="POST">
<textarea data="2" class="dcode" style="float: none; resize: none; width: 312px; height: 543px;">
<script type="text/javascript"><!--
google_ad_client = "pub-2151667935419035";
/* 120x600, created 7/17/08 */
google_ad_slot = "8233032726";
google_ad_width = 120;
google_ad_height = 600;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</textarea>
</form></span>
<button style="position: absolute; margin-right: 330px; bottom: 14px;"><img
src="img/v.png" style="margin-top: -2px; margin-left: 2px;" alt="add" height="28"/>שמור שינויים</button>
</div>
<script>
$("textarea.dcode").each(function (){
$(this).closest("div").children("span:first-child").children("div.dprev").html('<iframe class="adprev" name="preview'+$(this).attr("data")+'" src="pages/ad.php"></iframe>');
$(this).val($(this).text());
$('form[target="preview'+$(this).attr("data")+'"]').submit();
}).keyup(function (){
$(this).closest("div").children("span:first-child").children("div.dprev").html('<iframe class="adprev" name="preview'+$(this).attr("data")+'" src="pages/ad.php"></iframe>');
$('form[target="preview'+$(this).attr("data")+'"]').submit();
});
</script>
还有一些其他语言,但这并不重要,因为你可以看到我有两个iframe,但代码只适用于第一个。 (首先是梅林广告,第二个是谷歌广告,但即使我把梅林放在第二个文本框中,它也不起作用)。
答案 0 :(得分:1)
我自己没有尝试过这个解决方案,但你可能需要这样做:
iframe1.html?textbox=<encoded text from the textbox>
)。这将是允许的,就像你在同一个域中那样。iframe1.html
的同时在服务器上插入一个iframe以及您现在尝试执行的操作。这对浏览器来说似乎是静态的!希望它会有所帮助!如果它会,请让我知道,我感兴趣自己)