I need to click on the button on the previous screen by clicking on the button at the current screen Writing method for clicking on the current button screen is easy (see below) but I have troubles finding the button on the previous screen.
$('body.printing').prepend('<input type="button" value="Retry" id="RetryLetter"/>');
$("#RetryLetter").click(function()
{
// parent.history.back().$("#printLetter").click();
var prButton = document.referrer.getElementById("printLetter");
prButton.click();
// window.opener.$("#printLetter").click();
});
I tried several variants – so far nothing worked
parent.history.back().$("#printLetter").click()you should first read whathistory.back()is actually doing and returning: developer.mozilla.org/en-US/docs/DOM/window.history.document.referrerreturns a string so you cant use document methods on it