C
Cylix
As the title, How to do the ckecking in javascript?
Thanks!
Thanks!
Cylix said:As the title, How to do the ckecking in javascript?
Thanks!
As the title, How to do the ckecking in javascript?
Thanks!
var links = document.links;
for(var i = 0; i < links.length; i++)
{
//check here for specific link
//
//Example:
//if (links != null)
//{
// alert("A link exists");
// break;
//}
}
Evertjan. said:marss wrote on 01 feb 2007 in comp.lang.javascript:
As the title, How to do the ckecking in javascript?
Thanks!
var links = document.links;
for(var i = 0; i < links.length; i++)
{
//check here for specific link
//
//Example:
//if (links != null)
//{
// alert("A link exists");
// break;
//}
}
I think that the OP wants to test the existence of a website on line.
Test for an image you know should be there.
<img src=
'http://i.a.cnn.net/cnn/2007/WORLD/europe/02/01/blair.police/t1.blair.ap.jp
g'
onload='alert("cnn found")'
onerror='alert("cnn NOT found")'
Test for an image you know should be there.
<img src=
'http://i.a.cnn.net/cnn/2007/WORLD/europe/02/01/blair.police/t1.blair.ap.jp
g'
onload='alert("cnn found")'
onerror='alert("cnn NOT found")'
Randy Webb said:Evertjan. said the following on 2/1/2007 9:36 AM:
alert('Image found')
alert('Image not found')
The existence of an image doesn't tell you anything else about another file other than
that the server may, or may not, be up and running. Try setting the img src to the file
you want to check for.....
Evertjan. said the following on 2/1/2007 9:36 AM:
alert('Image found')
alert('Image not found')
The existence of an image doesn't tell you anything else about another
file other than that the server may, or may not, be up and running.
Try setting the img src to the file you want to check for.....
-Lost said the following on 2/1/2007 6:59 PM:
Ayup. Any file at all.
Then the xmlhttp way, perhaps testing only for the header,
would be my first choice.
Except for the cross-domain problems of doing that :-(
Evertjan. said:dd wrote on 02 feb 2007 in comp.lang.javascript:
Do it serverside, with jscript, clientside part being:
<a href='/testIt/testTheSiteFirst.asp?href=http://cnn.com/'>cnn</a>
either server.transfer-ing to notfound.asp
or response.redirect-ing to cnn.com
Um... so we went from client-side to server-side?
Your original check, allowing for Randy's suggestion is still the viable option.
No, the server is the most viable option. If a user has JS disabled or
doesn't have it at all then the client side aspect is broken. But, if
I wanted to verify the link then I would check it on the server and if
the URL didn't exist - don't output the link to start with. No client
side scripting at all.
server side scripting is not aviable for all,
though it should be at this time and age.
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.