How to paste text in <div> with chrome extension?

ε祈祈猫儿з 提交于 2019-12-13 02:56:59

问题


I would like to paste some pre-defined text to a textbox of a website using chrome extension. The target website is https://www.urlgot.com/. It is a seemly simple webpage with only one input textbox. I had found a solution to get my interesting DOM content. But how to manipulate the DOM to paste my text into the "placeholder" then? As a neophyte in chrome extension scripting, I really need some advice.

The DOM of interesting is as below,

<div class="form-group" id="urlFormGroup">
 <input type="text" class="form-control" id="mediaWebUrl" autocomplete="off" placeholder="paste link here ..." onpaste="parse()">

I think I should find some way to replace the "paste link here ..." text with my own text input. But I don't know how to do it. Thank you.


回答1:


You can use this:

document.getElementById('mediaWebUrl').setAttribute('placeholder','My own text...');


来源:https://stackoverflow.com/questions/56985016/how-to-paste-text-in-div-with-chrome-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!