In web development and design programming techniques, automatic page redirection is a widely used and practical method. Its application range is extensive: seamlessly forwarding legacy URLs from an old site to a new destination, showing an informational or transitional notice to visitors before redirecting, and managing customized routing scenarios.
Below is a collection of common code snippets and methods for automatic webpage redirection:
Method 1: Configuring Meta Refresh Between <HEAD> and </HEAD>
<head>
<meta http-equiv="refresh" content="10; url=https://www.vedfolnir.com">
</head>
Here, content="10; url=https://www.vedfolnir.com" instructs the browser to automatically redirect to https://www.vedfolnir.com after 10 seconds. Setting the value to 0 triggers an immediate redirect.
Method 2: Embedding an OnLoad Event in <BODY>
<body onload="parent.location='https://www.vedfolnir.com'">
Method 3: Using JavaScript Between <BODY> and </BODY>
Place any of the following scripts between the <body> tags:
<script language="javascript"> window.location="https://www.vedfolnir.com"; </script>
<script language="javascript"> location.href=('https://www.vedfolnir.com/'); </script>
<script language="javascript"> setTimeout("location.href='https://www.vedfolnir.com'", 10000); </script>
In snippet 3, the parameter 10000 is measured in milliseconds (ms), equaling 10 seconds.
Method 4: JavaScript Countdown Display Before Redirection
<script language="javascript">
var start = new Date();
start = Date.parse(start) / 1000;
var counts = 10;
function CountDown() {
var now = new Date();
now = Date.parse(now) / 1000;
var x = parseInt(counts - (now - start), 10);
if (document.formVedfolnir) {
document.formVedfolnir.clock.value = x;
}
if (x > 0) {
timerID = setTimeout("CountDown()", 100);
} else {
location.href = "https://www.vedfolnir.com";
}
}
</script>
<form name="formVedfolnir">
<input type="text" name="clock" size="3" value="10">
Redirecting in 10 seconds...
</form>
Method 5: Simulated Form Submission Between <BODY> and </BODY>
<form name="formjumpvedfolnir" action="https://www.vedfolnir.com/index.html" method="get"></form>
<script language="javascript"> document.formjumpvedfolnir.submit(); </script>Support Independent Perspectives & In-Depth Insights
Every thoughtful analysis and candid critique comes from our dedication to truth and quality. We choose not to follow sensational algorithms or clickbait headlines.
Sustaining independent research requires reader support. Make a one-time or monthly contribution, securely processed by Google.
Payments secured by Google · Manage or cancel anytime in your Google Account




Comments