I have a web site where people are directed via links from 12 different web sites.
For example, if the user was on www.chevy.com, and they clicked on a link to win a trip to an awards show, they would then be sent to my web site to register. After they fill out their information, they press submit, and are taken to the thank-you web page. After 10 seconds they get redirected back to www.chevy.com.
Is there a way to use JavaScript to pass the original referral URL (www.chevy.com) to the thank-you page, where I can load it into a meta refresh tag?
Thanks - Tony
8 9004
I have a web site where people are directed via links from 12 different web sites.
For example, if the user was on www.chevy.com, and they clicked on a link to win a trip to an awards show, they would then be sent to my web site to register. After they fill out their information, they press submit, and are taken to the thank-you web page. After 10 seconds they get redirected back to www.chevy.com.
Is there a way to use JavaScript to pass the original referral URL (www.chevy.com) to the thank-you page, where I can load it into a meta refresh tag?
Thanks - Tony
The code of Thank-You page will be something like this .... -
.
-
.
-
.
-
<head>
-
.
-
<META HTTP-EQUIV="Refresh" CONTENT="3;URL=http://www.some.org/some.html">
-
</head>
-
.
-
.
-
.
-
.
-
.
-
Kind regards,
Dmjpro.
I know how to do the meta refresh tag, but I need to pass the variable of the referral URL to the second web page.
For example - they start at www.chevy.com. They click on a link that takes them to a registration page. They fill out the registration information, and click "submit". Then they are taken to a "thank-you" page, where I redirect them after 10 seconds to their original web page of www.chevy.com.
So, I need to know how to pass the referral URL between the registration and thank-you pages.
Thanks - Tony
gits 5,390
Recognized Expert Moderator Expert
hi ...
you may pass it through a query-string that you append to the url: - whatever_url_you_have?referer=referal_url
in a webpage you retrieve the url with: - var url = window.location.href
and from that you may retrieve the query-string and the referal_url.
kind regards
I know how to do the meta refresh tag, but I need to pass the variable of the referral URL to the second web page.
For example - they start at www.chevy.com. They click on a link that takes them to a registration page. They fill out the registration information, and click "submit". Then they are taken to a "thank-you" page, where I redirect them after 10 seconds to their original web page of www.chevy.com.
So, I need to know how to pass the referral URL between the registration and thank-you pages.
Thanks - Tony
Hi Tony. I would use the http referrer property and place it in a cookie.
On your registration page, create the cookie with this code in the <head>: -
<script type="text/javascript">
-
function setCookie(name,val,days) {
-
// DATE OBJECT
-
var date = new Date();
-
// NUMBER OF MILLISECONDS IN A DAY
-
var milliseconds = 86400000;
-
// MULTIPLY, THEN ADD TO CURRENT TIME
-
date.setTime(date.getTime() + (days * milliseconds));
-
// SET EXPIRATION VARIABLE
-
var expires = '; expires=' + date.toGMTString();
-
// CONCATENATE TO CREATE COOKIE
-
document.cookie = name + '=' + val + expires + '; path=/';
-
}
-
window.onload = function(){
-
if(document.referrer != ''){
-
// DESTROY ANY PREVIOUS DUPLICATE COOKIE
-
setCookie('referrer','',-1);
-
// CREATE COOKIE ON REGISTRATION PAGE
-
setCookie('referrer',document.referrer,1);
-
}
-
}
-
</script>
-
Then on your thank-you page, read the cookie value, and set the redirect URL with this code in the <head>: -
<script type="text/javascript">
-
// RETURN VALUE
-
var ret = null;
-
// MILLISECONDS (10 SECONDS)
-
var t = 10000;
-
// READ COOKIE FUNCTION
-
function getCookie(cookiename){
-
-
// ANY / ALL COOKIES
-
var docCookie = document.cookie;
-
-
// CHECK TO SEE IF A COOKIE EXISTS
-
if(docCookie.length > 0){
-
-
// CONCATENATE NAME AND ASSIGNMENT OPERATOR
-
cookiename += '=';
-
-
// WHERE THE COOKIE NAME IS LOCATED
-
var cookiestart = docCookie.indexOf(cookiename);
-
-
// IF IT EXISTS
-
if(cookiestart != -1) {
-
-
// ADD START POSITION AND NAME LENGTH
-
cookiestart += cookiename.length;
-
-
// FIND END OF STORED VALUE
-
var cookieend = docCookie.indexOf(';', cookiestart);
-
-
// IF SEMICOLON IS NOT FOUND
-
if(cookieend == -1){
-
// CORRECT LENGTH
-
cookieend = docCookie.length;
-
}
-
-
// RETURN COOKIE VALUE
-
return unescape(docCookie.substring(cookiestart, cookieend));
-
}
-
}
-
-
// RETURN NULL IF NO COOKIE IS FOUND
-
return null;
-
}
-
// REDIRECT FUNCTION
-
function backToReferrer(){
-
// GET COOKIE
-
var url = getCookie('referrer');
-
// INITIATE PAGE JUMP
-
window.location.href = url;
-
}
-
window.onload = function(){
-
// AFTER 10 SECONDS, CALL REDIRECT FUNCTION
-
ret = setTimeout('backToReferrer()', t);
-
}
-
</script>
-
You must make sure the person doesn't directly enter the URL of the registration page directly into an address bar, or comes from a bookmark. The document.referr er only works on a legitimate page jump.
hi ...
you may pass it through a query-string that you append to the url: - whatever_url_you_have?referer=referal_url
in a webpage you retrieve the url with: - var url = window.location.href
and from that you may retrieve the query-string and the referal_url.
kind regards
So in my meta refresh tag, how do I reference the variable url?
[HTML] <meta http-equiv="refresh" content="2;url= +url+"> ??[/HTML]
Or like this? - <script type="text/javascript">
-
var name = "www.mysite.com"
-
document.write(name)
-
document.write("<meta http-equiv="refresh" content="2;url=+name+">)
-
</script>
Thanks - Tony
Thanks for the cookie example - I will give that a try.... Tony
The cookie worked great!!!
You are a genius.
Thanks - Tony
The cookie worked great!!!
You are a genius.
Thanks - Tony
Glad to hear it worked!
You could also improve the script by determining if the user has cookies disabled in his/her browser. That way, you could even dynamically give them instructions on how to turn cookies on for several browsers. I usually support 3 or 4 different browsers (Firefox 1.5+, MSIE6+, Opera 8+, and now Safari 3+ since it's available for Windows).
On your first page, the Registration page, you can place this code in the window.onload function: -
window.onload = function(){
-
// FAKE TESTING COOKIE
-
document.cookie = 'testing=123';
-
// IF COOKIE DIDN'T SET
-
if(document.cookie.indexOf('testing=') == -1){
-
// INSTRUCT THE USER TO ENABLE COOKIES
-
alert('You must enable cookies to continue!');
-
}
-
// ELSE, SET COOKIE
-
else {
-
// IF REFERRER
-
if(document.referrer != ''){
-
// DESTROY ANY PREVIOUS DUPLICATE COOKIE
-
setCookie('referrer','',-1);
-
// CREATE COOKIE ON REGISTRATION PAGE
-
setCookie('referrer',document.referrer,1);
-
}
-
// REFERRER ERROR
-
else {
-
// INSTRUCT USER TO NAVIGATE FROM MAIN PAGE
-
alert('You must come directly from our afilliate websites only!');
-
}
-
}
-
}
-
You can replace the alerts with custom code. You could have a <div> with style="display: none;" in the <body> section of the page, and then set the display to block by Javascript. The div could have graphics and text instructions magically appear...showin g the user what to do.
(I use alerts for testing, but never for a public web page!)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Consuelo Guenther |
last post by:
Hello,
I am having problems with passing variables between pages. I have the
following:
First asp page has the function:
-----------------------------------------------------------------------
<script language="JavaScript">
function addProcess(addPName,addSProcess,addPIndex)
{
var addProcessWindow =
window.open('second.asp','mywindow','width=400,height=200');
|
by: Kevin Lyons |
last post by:
Hello,
I am trying to get my select options (courses) passed correctly from
the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html
I am having difficulty getting the courses to pass the correct option
value and then be displayed at the following URL:
http://www.dslextreme.com/users/kevinlyons/selectResults.html
I am passing countries, products, and courses. The first two display
|
by: Kevin Lyons |
last post by:
Hello,
I am trying to get all of my form elements passed correctly from the
following URL:
http://www.dslextreme.com/users/kevinlyons/selectBoxes.html
to the following URL:
http://www.dslextreme.com/users/kevinlyons/selectResults.html
I am passing name, email, countries, cities, products, courses, etc.
The others display as they should on the subsequent page,
|
by: COVAD |
last post by:
To Whom It May Concern:
Good morning. I am Seann P. Courtney with Covad Communications and
the reason that I am contacting you is because I am looking for a
referral partner to do some business with. I will pay you $400.00,
free and clear, if during the normal course of your days business you
can refer a T1 line to me and I am cutting checks, free and clear, for
up to $175.00 if you can refer a business class SDSL line. It should be...
|
by: Evan |
last post by:
I have a web page with 2 frames. The left frame is running menu.aspx and the
right frame is running images.aspx. When a selection is made in menu.aspx I
call a method in images.aspx and pass a variable. The intention is that
images.aspx will take the variable and load images into its frame (the right
one) based on the variable passed. What actually happens is the method runs
in the left frame and ruturns the error "Object reference not...
| |
by: Phil Certain |
last post by:
Hi
I'm building a site that has publicly available pages and password
protected pages. Publicly available pages reside in:
/public
and password protected pages reside in:
/private
|
by: eatkins |
last post by:
Hi All-
I have a great full time, permanent opportunity with a client of mine in Jersey City, NJ. They are looking for a mid-senior level Java Developer with the following skills:
minimum 4 years programming exp.
Computer Science degree or equivalent
Java - 3 yrs
EJB, RMI or CORBA - 1yr
AWT/SWING - 1yr
Weblogic exp. a plus
|
by: vunet.us |
last post by:
Can I get the name of a referral page using JavaScript? Just really
wondering...
|
by: aelred |
last post by:
I have a web page where a member can open up a chat window (child window) with another member.
- From there the member can also navigate to other web pages.
- From other pages in the site, they may also open up new chat windows with other members (just not the same one).
- Each chat page is opened with the member name as the window name.
- When I log off from the web page, I would like all the chat windows to automatically close.
I...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |