0

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

9
  • 5
    What do you mean by "current" and "previous screen"? Web pages? That's impossible... you can only interact with what exists. Before you try adventures calls such as parent.history.back().$("#printLetter").click() you should first read what history.back() is actually doing and returning: developer.mozilla.org/en-US/docs/DOM/window.history. Commented Dec 20, 2012 at 22:38
  • But...what if that page is no longer loaded? How will you trigger a click on a page that is not (necessarily) being displayed Commented Dec 20, 2012 at 22:38
  • What do you mean previous screen? If its another page, the DOM is simply not loaded, you can't click it. Commented Dec 20, 2012 at 22:38
  • You cannot do anything on a page which is no longer loaded. also document.referrer returns a string so you cant use document methods on it Commented Dec 20, 2012 at 22:38
  • Yes, I mean previous pages. parent.history.back() returns me to the previous page but clicking does not work Commented Dec 20, 2012 at 22:39

2 Answers 2

4

document.referrer is just a string with the referring URL. It is not a DOM element that you can access.

http://wap.w3schools.com/jsref/tryit.asp?filename=tryjsref_doc_referrer

Sign up to request clarification or add additional context in comments.

2 Comments

If you open up a popup window however, you can access the parent window. See: stackoverflow.com/questions/2167455/…
It looks that I need to load previous page again not using history
0

So, it appeared that the only way to click on the button on the previous page is recreating the Get request from this button.
I memorize the request string (URL and parameters) in the session object and then repeat this request from the following page

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.