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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sijugeo
    New Member
    • Jul 2007
    • 42

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

    Hi ,

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

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

    Thanks in advance,
    Siju George.
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    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.

    Comment

    • sijugeo
      New Member
      • Jul 2007
      • 42

      #3
      It's fixed.

      I give the calling of the function in href="function( )"
      like this,
      <a href="function( )" id="functioncal ling">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

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        So you put history.go(-1) in a function and called that?

        Does the following not work?
        [code=html]<a href="someURL.h tml" onclick="return historyFunc();" >Back</a>[/code]where historyFunc is the function.

        Comment

        • studying
          New Member
          • Jul 2008
          • 1

          #5
          Code:
          <A href="javascript:back()">Back</A>
          In Js file,
          Code:
          function back(){
             history.go(-1);
          }

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            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.

            Comment

            • rajujrk
              New Member
              • Aug 2008
              • 107

              #7
              Hai better you this

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

              or

              <a href="#" onclick="histor y.back();">Back </a>

              Comment

              Working...