I made a small Chrome extension that automates field population for myself; that just currently works off a onkeydown event listener
on my document, that runs through the content.js file.
Additionally I have a popup menu (with popup.html and popup.js) that has a few handy links for me.
I'm trying to get one of the links in the popup menu create a small dialog (or popup browser window) that will contain a few links itself (perhaps on a html page), that when pressed, will populate some of the fields on the document it was opened on; similar to how the event listener does.
Currently I have a link, in my pop up, that just opens a 'popup' browser window, but I can't find how to get it to access the document it was opened on. Code as follows:
popup.js:
function newPopup(url) {
popupWindow = window.open(url,'popUpWindow','height=300,width=400,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes')
}
var link;
window.onload = function(){
link = document.getElementById('templates');
link.addEventListener('click', continueScript);
}
function continueScript(){
newPopup('https://www.example-site.com/');
}
popup.html:
<script src="popup.js"></script>
<li><a class="templates" id="templates" href="#"><i class="fa fa-wpforms"></i>Templates</a></li>
The field population simply works of a value editing principle, as demonstrated below:
function fillForms(summary, description) {
document.getElementById('example1').value = summary;
document.getElementById('example2').value = description;
document.getElementById('example2').focus();
}
Thanks for the help!