簡體   English   中英

如何使用jquery執行腳本標簽並將其附加到html元素

[英]How to execute and append a script tag to the html element using jquery

我有以下腳本標簽

<script src="http://bs.serving-sys.com/BurstingPipe/adServer.bs?cn=rsb&c=28&pli=3326580&PluID=0&w=728&h=90&ord=|RANDOM|&ncu=$$|CLICK|$$"></script>
<noscript>
    <a href="|CLICK|http://bs.serving-sys.com/BurstingPipe/adServer.bs?cn=brd&FlightID=3326580&Page=&PluID=0&Pos=4688" target="_blank">
        <img src="http://bs.serving-sys.com/BurstingPipe/adServer.bs?cn=bsr&FlightID=3326580&Page=&PluID=0&Pos=4688" border=0 width=728 height=90>
    </a>
</noscript>

這是在執行時,我只是將其添加到html正文段中。

但是如果我使用jquery將這個標簽動態添加到html元素中,它就不會執行。

在附加到html元素之前,我還嘗試使用jQuery('')將其轉換為dom。

請查看我正在執行的jQuery代碼。

var testUrl = $('<script src="http://bs.serving-sys.com/BurstingPipe/adServer.bs?cn=rsb&c=28&pli=3326580&PluID=0&w=728&h=90&ord=|RANDOM|&ncu=$$|CLICK|$$"></script><noscript><a href="|CLICK|http://bs.serving-sys.com/BurstingPipe/adServer.bs?cn=brd&FlightID=3326580&Page=&PluID=0&Pos=4688" target="_blank"><img src="http://bs.serving-sys.com/BurstingPipe/adServer.bs?cn=bsr&FlightID=3326580&Page=&PluID=0&Pos=4688" border=0 width=728 height=90></a></noscript>');
$('#previewImgDiv').html(testUrl);

有人可以幫我嗎?

您可以使用postscribe來做到這一點。那是專門用於異步編寫javascript的

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM