簡體   English   中英

執行以字符串形式存儲的 JavaScript 代碼<Script> tag

[英]Execute JavaScript code stored as a string with <Script> tag

這篇文章與這里提出的問題更相關。 執行以字符串形式存儲的 JavaScript 代碼

但我的問題在這里似乎沒什么不同。

當我嘗試執行這樣的代碼時,它會錯誤地輸出unexpected token '<'

setTimeout('<script>console.log("some string")</script>', 1);

面臨同樣的問題new Function( '<script>console.log("some string")</script>' )

    let incomingString='<script>console.log("some string")</script>';
    let f = new Function(incomingString.replace("<script>","").replace("</script>",""));
    f();

節點輸出上的 Thiw 代碼:一些字符串,但它不能在代碼片段上運行

暫無
暫無

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

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