简体   繁体   English

如何将输入框(html 文件)中的值传递给 javascript 注入文件(inject.js)?

[英]How can I pass a value from an input box (html file) to a javascript inject file (inject.js)?

I am wondering if there is a way to pass a value from a input box to another file (html to javascript) (Been stuck on this for couple days now and it's driving me insane) the problem with this is that it is a inject file and I think they don't work in the same fashion as other js files.我想知道是否有一种方法可以将输入框中的值传递到另一个文件(html 到 javascript)(已经被困在这个问题上几天了,这让我发疯了)问题是它是一个注入文件而且我认为它们的工作方式与其他 js 文件不同。 So please if anyone has any idea please share.因此,如果有人有任何想法,请分享。

What I want to do:我想做的事:

  • Have an Input box in html file.在 html 文件中有一个输入框。
<input type="text" id="paste" placeholder = "paste text">
  • Have whatever value input get sent to a inject.js file.将任何值输入发送到 inject.js 文件。

PS this is for a google extension so bear that in mind. PS这是一个谷歌扩展所以记住这一点。

Seems you can use a content script to monitor this iuput box, such as似乎您可以使用内容脚本来监视此 iuput 框,例如

document.querySelector('input').addEventListener('input',function(){...executer...})

And then every time the input text is changed, you can do something in executer然后每次输入文本改变时,你可以在执行器中做一些事情

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我如何将不同变量的多个不同值从 popup.js 发送到 inject.js 以便可以在 inject.js 脚本中使用? - How would I send multiple different values of different variables from popup.js to inject.js so those can be used in the inject.js script? 在Chrome网络中检查标题时的Inject.JS文件 - Inject.JS file when inspecting headers in chrome network 如何将数组从 background.js 传递给 inject.js(内容)脚本(Chrome 扩展程序) - How to pass an array from background.js to inject.js (content) script (Chrome Extension) Inject.js无法在页面上加载? - Inject.js not loading on page? 在background.js下执行的inject.js文件中使用JQuery - Use JQuery in an inject.js file executed under background.js Webpack:如何将JavaScript注入HTML而不是单独的JS文件 - Webpack: How to inject javascript into the HTML instead of separate JS file 我可以使用 Webpack 将 Javascript 直接注入 HTML 文件吗? - Can I directly inject Javascript into an HTML file with Webpack? 如何将 JS 注入已加载的 JS 文件中? - How can I inject JS into already loaded JS file? 如何将变量值从GULP注入到JS文件中 - How to inject variable value into JS file from GULP 如何将大型 HTML 文件注入 iFrame? - How can I inject large HTML file into iFrame?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM