![](/img/trans.png)
[英]How can I pass a value from an input box (html file) to a javascript inject file (inject.js)?
[英]How can I inject JS into already loaded JS file?
假設我有一個網站,我想知道我是否可以在已加載的 JS 文件中注入 Javascript。 就像我想從已經加載的 JS 中獲取 console.log 有什么辦法嗎?
您可以添加 cript 標簽或更改現有標簽的內容:
<html> <script id="script-a"></script> <body> <div> </div> <script id="script-b"> const scriptA = document.getElementById('script-a'); scriptA.innerText = "const myLog = () => console.log('BLABLA')"; myLog(); </script> </body> </html>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.