Hello. i'm just approaching Javascript through an old book.
do you see anything wrong in the funcions listed below?
<html>
<head><title>Link Test</title> </head>
<body>
<a id="mylink" href="http://joy.indivia.net">Click
me</a><br />
<script type="text/javascript">
onError = errorHandler
url = mylink.href
document.write('The URL is ' + url)
function errorHandler(message, url, line)
{
out = "Sorry, an error was encountered.\n\n";
out += "Error: " + message + "\n";
out += "URL: " +url + "\n";
out += "Line: " +n line + "\n\n";
out += "Click OK to continue.\n\n";
alert(out);
return true;
}
</script>
<noscript>
Your browser doesn't support or has disabled
Javascript
</noscript>
</body>
</html>
And in those other functions?
<html><head><title>Ajax XML Example</title></head><body><center />
<h1>Loading a web page into a div</h1>
<div id='info'>This sentence will be replaced</div>
<script>
// params = "url=oreilly.com"
nocache = "&nocache=" + Math.random() * 1000000
url = "rss.mews.yahoo.com/rss/topstories"
request = new ajaxRequest()
request.open("GET", "xmlget.php?url=" + url + nocache, true)
// request.setRequestHeader("Content-type",
"application/x-www-form-urlencoded")
// request.setRequestHeader("Content-length", params.length)
// request.setRequestHeader("Connection", "close")
out ="";
request.onreadystatechange = function()
{
if(this.readyState == 4)
{
if (this.status == 200)
{
if (this.responseText != null)
{
titles = this.responseXML.getElementsByTagName('title')
for (j = 0 ; j < titles.length ; ++j)
{
out += titles[j].childNodes[0].nodeValue + '<br/>'
}
document.getElementById('info').innerHTML = out
}
else alert("Ajax error: No data received")
}
else alert("Ajax error: " this.statusText)
}
}
request.send(null)
function ajaxRequest()
{
try:
{
var request = new XMLHttpRequest()
}
catch(e1)
{
try
{
request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch(e2)
{
try
{
request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch(e3)
{
request = false
}
}
}
return request
}
</script></body></html>
Firebug and the crome debugger doesn't say anything about any error, but it
simply doesn't accomplish the tasck.
Is there something wrong?
tab1ta
--
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/prototype-scriptaculous/-/LUOs7TBQ0TIJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.