By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,480 Members | 1,743 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,480 IT Pros & Developers. It's quick & easy.

history.go(-1), is not working.

P: 42
Hi ,

I have a problem. In my aspx page I have a onClick="history.go(-1)"

Later I moved it into external .js file. but it is not working. Can anyone help me?

Thanks in advance,
Siju George.
Jul 29 '08 #1
Share this Question
Share on Google+
6 Replies


acoder
Expert Mod 15k+
P: 16,027
What do you mean by moving it to an external JS file? If it's in an onclick, that means you'll have to change the code to put it in an external file.
Jul 29 '08 #2

P: 42
It's fixed.

I give the calling of the function in href="function()"
like this,
<a href="function()" id="functioncalling">Call</a>


Sorry its confusing I know, actually its an anchor tag used with onlick earlier, however when changed the method calling to hrref, it worked.

Siju
Jul 31 '08 #3

acoder
Expert Mod 15k+
P: 16,027
So you put history.go(-1) in a function and called that?

Does the following not work?
Expand|Select|Wrap|Line Numbers
  1. <a href="someURL.html" onclick="return historyFunc();">Back</a>
where historyFunc is the function.
Jul 31 '08 #4

P: 1
Expand|Select|Wrap|Line Numbers
  1. <A href="javascript:back()">Back</A>
In Js file,
Expand|Select|Wrap|Line Numbers
  1. function back(){
  2.    history.go(-1);
  3. }
Jul 31 '08 #5

acoder
Expert Mod 15k+
P: 16,027
Studying, welcome to Bytes and thanks for your contribution.

You should avoid the "javascript:" protocol in href attributes. You can use the function in onclick and point the href to a real URL in case JavaScript is disabled.
Jul 31 '08 #6

100+
P: 107
Hai better you this

<a href="#" onclick="history.go(-1);">Back</a>

or

<a href="#" onclick="history.back();">Back</a>
Aug 16 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.