Skip to main content
chandrup
Participant
November 8, 2010
Question

How to use a back button in action pages?

  • November 8, 2010
  • 1 reply
  • 691 views

Hi all,

I have created a user login page,home page and user profile page.

If the user provide correct username and password in the login page he will be taken to home page.

In the home page he will be having his username and a link to view his profile.

When the user click on the link "My Profile(user profile)" he wil be taken to that page.

In my profile page the user can edit only his firstname,lastname and password .

On the user profile page i have placed a Back Button(using javascript: on onclick event i have used history.back()) to go back to home page after editing his profile.

If the user edit his profile for n-number of times then atlast if he wants to go back to home page-then he wil cilck the back button.

Now the problem occurs like the back button not going to home page and it simply going back with the edited history.

How to use a back button in action pages; without repeating the actions done on the page; how to redirect to the users home page?

I simply used the hyperlink in userprofile page to go to home page but when i click onit it is displaying blank home page.

I'm using hibernate orm mapping; cflogin and cflogout tags.

Any help appreciated,

Chandru P

    This topic has been closed for replies.

    1 reply

    Inspiring
    November 8, 2010

    Use an anchor tag.

    chandrup
    chandrupAuthor
    Participant
    November 9, 2010

    Hi Dan,

    Dan Bracuk wrote:

    Use an anchor tag.

    I simply used the hyperlink(<a href="home.cfm">Home</a>) in userprofile page to go to home page but when i click onit it is displaying blank home page.

    Thanks for ur reply,

    Chandru P

    BKBK
    Community Expert
    Community Expert
    November 9, 2010

    chandrup wrote:

    Hi Dan,

    Dan Bracuk wrote:

    Use an anchor tag.

    I simply used the hyperlink(<a href="home.cfm">Home</a>) in userprofile page to go to home page but when i click onit it is displaying blank home page.

    I can see your problem. You may use javascript:history.go(-1), javascript:history.go(-2), ..., to go back one page, two pages, and so on. But how does one go back an arbitrary n pages? The link href="home.cfm" isn't a good solution for the browser. It makes a new call to the server which, as you may have discovered, can overwrite all the changes made at the browser. 

    You should use the Javascript variable history.length. If you open n links in succession, starting from page0.cfm, then the browser holds the value of history.length as n. So, experiment with something like

    <a href="javascript:history.go(-history.length)">Go home</a>

    or

    <a href="javascript:history.go(-history.length+1)">Go home</a>