我正在播放javascript嵌入式,其中的代碼是從服務器獲取的javascript代碼將生成橫幅。從我的服務器將javascript移至標籤div id
實例JavaScript是:
<script type='text/javascript'>
<!--//<![CDATA[
var m3_u = (location.protocol=='https:'?'https://203.130.226.231/advediax/www/delivery/ajs.php':'http://203.130.226.231/advediax/www/delivery/ajs.php');
var m3_r = Math.floor(Math.random()*99999999999);
if (!document.MAX_used) document.MAX_used = ',';
document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
document.write ("?zoneid=1");
document.write ('&cb=' + m3_r);
if (document.MAX_used != ',') document.write ("&exclude=" + document.MAX_used);
document.write (document.charset ? '&charset='+document.charset : (document.characterSet ? '&charset='+document.characterSet : ''));
document.write ("&loc=" + escape(window.location));
if (document.referrer) document.write ("&referer=" + escape(document.referrer));
if (document.context) document.write ("&context=" + escape(document.context));
if (document.mmm_fo) document.write ("&mmm_fo=1");
document.write ("'><\/scr"+"ipt>");
//]]>-->
</script>
,並在下面有標籤的div ID旗幟。
<div id="banner">For banner</div>
<script>
// Possible to move script from my server into tag banner?
// If yes, how to do it?
</script>
條件HTML現在大約是這樣如下:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script type='text/javascript'>
<!--//<![CDATA[
var m3_u = (location.protocol=='https:'?'https://203.130.226.231/advediax/www/delivery/ajs.php':'http://203.130.226.231/advediax/www/delivery/ajs.php');
var m3_r = Math.floor(Math.random()*99999999999);
if (!document.MAX_used) document.MAX_used = ',';
document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
document.write ("?zoneid=1");
document.write ('&cb=' + m3_r);
if (document.MAX_used != ',') document.write ("&exclude=" + document.MAX_used);
document.write (document.charset ? '&charset='+document.charset : (document.characterSet ? '&charset='+document.characterSet : ''));
document.write ("&loc=" + escape(window.location));
if (document.referrer) document.write ("&referer=" + escape(document.referrer));
if (document.context) document.write ("&context=" + escape(document.context));
if (document.mmm_fo) document.write ("&mmm_fo=1");
document.write ("'><\/scr"+"ipt>");
//]]>-->
</script>
<div id="banner"> </div>
</body>
</html>
而且我想,如下面:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div id="banner">
<script type='text/javascript'>
<!--//<![CDATA[
var m3_u = (location.protocol=='https:'?'https://203.130.226.231/advediax/www/delivery/ajs.php':'http://203.130.226.231/advediax/www/delivery/ajs.php');
var m3_r = Math.floor(Math.random()*99999999999);
if (!document.MAX_used) document.MAX_used = ',';
document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
document.write ("?zoneid=1");
document.write ('&cb=' + m3_r);
if (document.MAX_used != ',') document.write ("&exclude=" + document.MAX_used);
document.write (document.charset ? '&charset='+document.charset : (document.characterSet ? '&charset='+document.characterSet : ''));
document.write ("&loc=" + escape(window.location));
if (document.referrer) document.write ("&referer=" + escape(document.referrer));
if (document.context) document.write ("&context=" + escape(document.context));
if (document.mmm_fo) document.write ("&mmm_fo=1");
document.write ("'><\/scr"+"ipt>");
//]]>-->
</script>
</div>
</body>
</html>
在這個問題我不能插入並粘貼我的腳本的div id橫幅,因爲其他內容擁有。所以我只擁有主調javascript。 我的問題,可能將JavaScript從我的服務器移動到標籤div id橫幅?
感謝
嗨感謝您的回覆,我不能插入「腳本的字符串(含標籤)」,我的劇本我服務器將在上面並且已經加載。我必須從正則表達式中得到字符串。 – 2013-03-28 04:04:02
將「JavaScript from the server」片段更改爲查找'#banner'元素並插入腳本... – xandercoded 2013-03-28 04:05:38
還有其他方法嗎?我改變了我的帖子,以瞭解我的情況。 – 2013-03-28 04:12:47