简体   繁体   中英

how to inject text into a textbox with firefox extension

This question was probably asked few time by now... but I didn't find any solution in the last 2 days so I'm asking it in here.
I need to inject some text into a textbox that has an ID and I already know it. the scenario is like that:

  • The user insert a text into the textbox inside my toolbar.
  • The user clicks on a button in my toolar.
  • The function in the button should redirect the user to a new page in the background, inject a text into a specified textbox and click a button in that webpage.
  • Return a link that is generated on the webpage.

I know how to open a new webpage. now all is left is the rest. I can't seem to inject the text into the specified textbox.

Also to note, I can't use greasemonkey on this project and that's why I will have to write everything I'll need to write.

If you can direct me to the starting point for this problem it would be nice.

The textbox is XUL textbox or html textarea?

It look like your scenario is simulate submit a form in background, why not just directly create a XMLHttpRequest to do this, no need to interactive with UI.

Update:

If it is a XUL textbox, you can use value property

var textbox = window.document.getElementById(textboxId);
if (textbox) {
    textbox.value = 'your text';
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM