how does this script work?

S

Steve Richter

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,GeobytesRegion">
</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>
 
M

Michael Winter

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
 
S

Steve Richter

Michael said:
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
 
T

Thomas 'PointedEars' Lahn

Steve said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,199
Messages
2,571,045
Members
47,643
Latest member
ashutoshjha_1101

Latest Threads

Top