By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,009 Members | 1,487 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,009 IT Pros & Developers. It's quick & easy.

how does this script work?

P: n/a
How does the following javascript work? After the first script runs the
variables "sGeobytesCity", "sGeobytesRegion" and "sGeobytesCountry"
contain values that have been set somehow by the
"src=http://gd.geobytes.com..."

how does it do that? It appears to pass the string
"variables=GeobytesCountry, ..." and on return the document variable
"sGeobytesCountry" contains a value!!

thanks,

-Steve

------------------------------------------------

<html>
<body>
<script language="Javascript"
src="http://gd.geobytes.com/Gd?after=-1&variables=GeobytesCountry,GeobytesCity,GeobytesR egion">
</script>

<script language="javascript">
if(typeof(sGeobytesCountry) != "undefined" &&
typeof(sGeobytesRegion) != "undefined" &&
typeof(sGeobytesCity) != "undefined")
{
var url = 'CookieDemo.aspx?IPCity=' +
sGeobytesCity + '&IPRegion=' + sGeobytesRegion +
'&IPCountry=' + sGeobytesCountry ;
document.write("<META HTTP-EQUIV='Refresh' CONTENT='0; URL="+url+"'>");
}
else
{
document.write( "<META HTTP-EQUIV='Refresh' CONTENT='0;
URL=CookieDemo.aspx'>" ) ;
}
</script>

</body>
</html>

Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On 27/05/2005 23:49, Steve Richter wrote:
How does the following javascript work? After the first script runs the
variables "sGeobytesCity", "sGeobytesRegion" and "sGeobytesCountry"
contain values that have been set somehow by the
"src=http://gd.geobytes.com..."


This has nothing to do with Javascript. The Gd resource will be a
server-side script written in PHP, ASP, or whatever, that outputs a
series of var statements. Which variables are written is determined by
the names listed in the query string. Nothing special - just like a
dynamically generated HTML document, only a script instead.

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #2

P: n/a


Michael Winter wrote:
On 27/05/2005 23:49, Steve Richter wrote:
How does the following javascript work? After the first script runs the
variables "sGeobytesCity", "sGeobytesRegion" and "sGeobytesCountry"
contain values that have been set somehow by the
"src=http://gd.geobytes.com..."


This has nothing to do with Javascript. The Gd resource will be a
server-side script written in PHP, ASP, or whatever, that outputs a
series of var statements. Which variables are written is determined by
the names listed in the query string. Nothing special - just like a
dynamically generated HTML document, only a script instead.


Wow! When do I finally know everything there is to know about web
programming?

thanks for the explanation, Mike. The Src= causes javascript to be
returned from the URL, and that script contains a series of "var =
xxx;" statements. Those vars are then available to other scripts in
the document.

Who invented all this stuff??

-Steve

Jul 23 '05 #3

P: n/a
Steve Richter wrote:
Wow! When do I finally know everything there is to know about web
programming?
Perhaps never.
[...]
Who invented all this stuff??


Tim Berners-Lee started the Web by inventing HTML.
PointedEars
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.