js能否判断一个链接的http状态 可以向地址发送请求 js+ajax,然后看返回状态是否为404,当然你得有权限,能模拟提交参数 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 IE启用跨域请求,用ajax的status属性可以得到对应的状态 var url = "http://bbs.csdn.net/topics/3907043101";jQuery.ajax({ type: "post", async: false, dataType: "json", url: "Default.aspx/UrlIsExist", contentType: "application/json; charset=utf-8", cache: false, data: '{url:\"' + url + '"}', success: function (data) { if (data.d == "true") { //地址可用 }else{ //地址不存在 } }, Error: function (error) { alert(error); } });[WebMethod]private static string UrlExistsUsingHttpWebRequest(string url) { HttpWebRequest webReqst = (HttpWebRequest)WebRequest.Create(url); webReqst.Method = "GET"; webReqst.KeepAlive = true; webReqst.Timeout = 300; string result = false; try { HttpWebResponse webResponse = (HttpWebResponse)webReqst.GetResponse(); if (webResponse.StatusCode == HttpStatusCode.OK && webResponse.ContentLength < 1024 * 1024) { result = "true"; } } catch { result = "false"; } return result; } js 兼容性问题 滚动条事件触发解决办法 修改一下倒计时的程序不成功,请帮忙看看,谢谢 这个使用的什么技术? 我想在load首页时,隔段时间再弹出窗口,问题是:我在关闭窗口时,不久又弹出来了..晕... 正则表达式中有个 "预测先行搜索" 的概念,能不能解释一下 打印问题,如何只打印页面上指定DIV里的内容? 关于日期下拉框的填充问题 如何看到src包含来js代码 很初级原始简单的问题! jquery draggable 拖动 怎么不用uploadify按钮,用js直接调用事件来上传
var url = "http://bbs.csdn.net/topics/3907043101";
jQuery.ajax({
type: "post",
async: false,
dataType: "json",
url: "Default.aspx/UrlIsExist",
contentType: "application/json; charset=utf-8",
cache: false,
data: '{url:\"' + url + '"}',
success: function (data) {
if (data.d == "true") {
//地址可用
}else{
//地址不存在
}
},
Error: function (error) {
alert(error);
}
});
[WebMethod]
private static string UrlExistsUsingHttpWebRequest(string url)
{
HttpWebRequest webReqst = (HttpWebRequest)WebRequest.Create(url);
webReqst.Method = "GET";
webReqst.KeepAlive = true;
webReqst.Timeout = 300;
string result = false;
try
{
HttpWebResponse webResponse = (HttpWebResponse)webReqst.GetResponse(); if (webResponse.StatusCode == HttpStatusCode.OK && webResponse.ContentLength < 1024 * 1024)
{
result = "true";
}
}
catch
{
result = "false";
}
return result; }