Solved

Redirect Traffic To Previous Page

Posted on 2006-06-27
11
177 Views
Last Modified: 2012-05-05
How do you redirect to a previous page

e.g.

<meta http-equiv='refresh' content='4;URL='javascript:history.go(-1)' />

but obviously this does not work
0
Comment
Question by:doyledom
  • 3
  • 2
  • 2
  • +2
11 Comments
 
LVL 20

Accepted Solution

by:
Gawai earned 25 total points
ID: 16998637
u can use javascript instead

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

<body onload="Goback()">

0
 

Author Comment

by:doyledom
ID: 17002439
So how do I call a javascript function in ASP?

Thanks.
0
 

Author Comment

by:doyledom
ID: 17002442
Also, it needs to be delayed for four seconds.
0
 
LVL 2

Assisted Solution

by:bowen18
bowen18 earned 25 total points
ID: 17003095
>"So how do I call a javascript function in ASP?"
Use it like you would any other piece of HTML...just close off the %>

>"Also, it needs to be delayed for four seconds."
To set the delay for four seconds, modify gawai's code to:

<script language="JavaScript">
function Goback() {
history.go(-1);
}
</script>
<body onload="setTimeout('Goback()',4000)">

0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 20

Expert Comment

by:Gawai
ID: 17003496
no need to ' sign just

<body onload="setTimeout(Goback(),4000)">
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 17026071
Actually, setTimeout must take a string as its first parameter. Otherwise, it just seems to ignore the time interval and immediately execute the function you include (in IE6 and FF1.5 on Windows OS at least). I'm not knowledgeable enough in Javascript to explain why, unfortunately.

For instance, try running this code in IE6 and/or FF1.5:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Testing setTimeout</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=ISO-8859-1" />
<script type="text/javascript">
/* <![CDATA[ */

function Goback()
{
    history.go(-1);
}

/* ]]> */
</script>
</head>
<body onload="setTimeout(Goback(), 4000);">
</body>
</html>

Don't worry about the xhtml; I am just trying to get familiar with it, and I probably still made mistakes in either syntax or whatnot. The important part to notice is that there are no quotes surrounding the Goback() function. After running the sample page, try inserting quotes, and notice the difference.

Ted
0
 
LVL 20

Expert Comment

by:Gawai
ID: 17026085
Zyloch, you are making code too complicated. code works fine without all these optional tags.

just

<script language="JavaScript">
function Goback() {
history.go(-1);
}
</script>
<body onload="setTimeout(Goback(),4000)">

no need of all those optional tags u have stated here
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 17026105
I know that :D. I was just practicing my xhtml. But the point I was trying to make is that you do need the quotes around Goback() in setTimeout(). Without them, the second parameter specifying the number of milliseconds to delay is ignored.

Ted
0
 
LVL 19

Expert Comment

by:dakyd
ID: 17142758
<no points for me>

Technically, you're both right and wrong, Ted.  You're right that putting the parentheses around the function call means that it will get executed immediately.  That means that gawai's code will execute onload, rather than 4 seconds after onload.

However, you're wrong in that you *have* to have the quotes.  There are actually two different ways to call setTimeout (and setInterval, for that matter).  One is to pass a function object as the first argument, and the second one is to pass a string.  The first way would look like this:

<html>
<head>
<script type="text/javascript">
function Goback() {
alert("called Goback");
history.go(-1);
}
</script>

<body onload="setTimeout(Goback,4000)">
hello world
</body>
</html>

Notice that there's no paren's for the first argument, so I'm actually passing the function object.  Without the parens, it doesn't execute immediately, and setTimeout knows to execute the function after 4000 milliseconds.

With all that said, bowen looks he/she gave the correct answer first, IMHO.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
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)

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now