Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 11-15-2005, 03:44 AM looking for a code
Novice Talker

Posts: 6
Trades: 0
Hello!
I would like to find a code that according to the reffereral url when the user click on one of the external link he will get different id.
For example:
If referral_URL is yahoo
Than
Id=1234
If referral_URL is Google
Than
Id=9876
Else
Id=1111

Thanks!
__________________

Please login or register to view this content. Registration is FREE
;
Please login or register to view this content. Registration is FREE
;
Please login or register to view this content. Registration is FREE

betty smart is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-16-2005, 03:44 AM
Novice Talker

Posts: 6
Trades: 0
OK – I realized I need an improvement.
Each incoming campaign URL as a parameter: id=Google or id=overture.
I would like the script to say:
If id=Google (we need to part the url string from http://search.google.com/?id=google into just id=Google)
Then
Id1=xxxx
If id=overture
Than id1=yyyyy
Else (no id parameter in the incoming link)
Id1=zzzzz
End.


Thanks!
__________________

Please login or register to view this content. Registration is FREE
;
Please login or register to view this content. Registration is FREE
;
Please login or register to view this content. Registration is FREE

betty smart is offline
Reply With Quote
View Public Profile
 
Old 11-16-2005, 10:57 AM
funkdaddu's Avatar
Web Design Snob

Posts: 635
Trades: 0
You might be better off with a server side code instaead of JS, but here goes:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

	<head>
		<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
		<title>Untitled Page</title>
		<script type="text/javascript"><!--
function cbegeturlArguments() { 
	var idx = location.href.indexOf("?"); 
	var params = new Array(); 
	if (idx != -1) { 
		var pairs = location.href.substring(idx+1, location.href.length).split("&"); 
		for (var i=0; i<pairs.length; i++) { 
			nameVal = pairs[i].split("="); 
			params[i] = nameVal[1]; 
			params[nameVal[0]] = nameVal[1]; 
		} 
	} 
	return params;
}

var urlArgs = cbegeturlArguments();
var Id1 = "zzzzz";
switch (urlArgs["id"]) {
	case "google":
	Id1 = "xxxxx";
	break;

	case "overture":
	Id1 = "yyyyy";
	break;
}

//-->
</script>
	</head>

	<body bgcolor="#ffffff">
		<p><script>document.write(Id1)</script></p>
		<p><a href="refer.html">No Link</a></p>
		<p><a href="refer.html?id=google">Google Link</a></p>
		<p><a href="refer.html?id=overture">Overture Link</a></p>
	</body>

</html>
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Reply     « Reply to looking for a code
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.17449 seconds with 12 queries