2011-06-08 71 views

回答

4

我想你想嘗試加載URL - 使用XMLHttpRequest爲:

var request = new XMLHttpRequest(); 
request.open("GET", url); 
request.onload = function() 
{ 
    if ((request.status >= 200 && request.status < 300) || request.status == 304) 
     alert("Exists!"); 
    else 
     alert("HTTP response isn't success, URL doesn't exist or is currently unavailable"); 
}; 
request.onerror = function() 
{ 
    alert("Loading URL errored out, server doesn't exist or is currently unavailable"); 
}; 
request.send(null); 
+1

由於跨站點腳本限制,這不起作用,它總是會說如果url位於腳本域之外,則它不可用。 – gnur 2011-06-08 10:54:57

+2

@gnur:問題是關於Firefox擴展,沒有任何限制。 – 2011-06-08 10:57:35

+0

啊對了,忘了那個部分:) – gnur 2011-06-08 10:58:12