Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

javascript  onclick='history.go(-3); FAILS!

Posted on 2014-07-21
11
Medium Priority
?
251 Views
Last Modified: 2014-07-23
Hey Guys,
What's wrong with this javascript?
No matter what history I give it (-1) (-2)  (-3) (-4)   it only refreshes the page it is on.
If I change the "type" from "submit" to "button" nothing happens at all.
onclick='history.go(-3);return true;' has no effect either.
Have I lost my mind again?
Sas
<form> <input name='Back' type='submit'  value='Go Back' onclick='history.go(-3);' style='height: 22px; width:280px; FONT-SIZE:12px; font-family:Arial;'  >
</form>

Open in new window

0
Comment
Question by:sasnaktiv
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 13

Accepted Solution

by:
duncanb7 earned 2000 total points
ID: 40210925
You need to do with window.history as following code
in tag or function

Duncan

<form> <input name='Back' type='submit'  value='Go Back' onclick='javascript:window.history.go(-3);' style='height: 22px; width:280px; FONT-SIZE:12px; font-family:Arial;'  >
</form>

Open in new window


<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/JavaScript">

	function goBack() {
    window.history.go(-1);
}	
	</script>

</head>

<body >

	<button onclick="goBack()">Go Back</button>
</body>
</html>

Open in new window

0
 
LVL 1

Author Comment

by:sasnaktiv
ID: 40211482
Thanks for getting back to me Duncan.
Unfortunately I still have the problem -- with either of your suggestions.
Go figure?
Sas
0
 
LVL 13

Expert Comment

by:duncanb7
ID: 40211501
Did you enable javascript enabed on browser> What browser are you using ?

If javascript is not enabled, you could not view the error message at browser develper tools ?
You know where is button for developer tools on browser ?

the html page, I tried, it works at my sides, no any issue
Why not send us  your whole page ?

Duncan
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 13

Expert Comment

by:duncanb7
ID: 40211505
copy wrong code to your, missing onclick="javascript:..."

Try it

Duncan
<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/JavaScript">

	function goBack() {
    window.history.go(-1);
}	
	</script>

</head>

<body >

	<button onclick="javascript:goBack();">Go Back</button>
</body>
</html>

Open in new window

0
 
LVL 1

Author Comment

by:sasnaktiv
ID: 40211681
Sorry Duncan,
Nothing seems to be working. Not even when I create direct buttons (targeted to the correct document) using post or get. It just keeps refreshing the existing page.
Sas
0
 
LVL 13

Expert Comment

by:duncanb7
ID: 40211689
That page works at my side.
Could you send us the "not working" page ? including related code such as javascript

Duncan
0
 
LVL 1

Author Comment

by:sasnaktiv
ID: 40211980
Sorry Duncan,
The page is quite complex ad proprietary. So I can't send it along. I guess I'll have to continue trying to fix it or just give up on it.
How can I award you the points?
Sas
0
 
LVL 13

Expert Comment

by:duncanb7
ID: 40211990
Just close this thread  without any points since I didn't solve your  issue

Duncan
0
 
LVL 1

Author Comment

by:sasnaktiv
ID: 40212010
But there's nothing wrong with any of the code you suggested.
And I want to do what's right by you.
Sas
0
 
LVL 1

Author Closing Comment

by:sasnaktiv
ID: 40214653
Thanks for the help and attention Duncan. You are the only person who responded to my question.
Sas
0
 
LVL 13

Expert Comment

by:duncanb7
ID: 40214661
Thanks for your points

Reminder and Note for other viewer: the solution is NOT fixed to author final question completely

have a nice day

Duncan
0

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question