如何检查URL存在? [英] How to check URL existence ?

查看:72
本文介绍了如何检查URL存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我有以下HTML代码正在对页面进行GET,比如说

MyUrl.aspx:


< body>

< form name =" form1"方法= QUOT;获得"行动= QUOT; MyUrl.aspx" id =" form1">

< input type =" hidden"名称= QUOT; ClickedElement" ID = QUOT;信使" />

< / form>

< / body>

其中Submit()是在调用的javascript函数中完成的在

onclick on some element。


我的问题是:当MyUrl.aspx为

时,如何阻止表单提交?可用吗?


javascript功能是:


功能点击(MyControl)

{

var _CellContent = document.getElementById(" Messenger");

_CellContent.value = MyControl.id;

document.form1.submit();

}


感谢您的帮助,


Pam

Hi Guys,

I have the following HTML code which is doing a GET to a page, say
MyUrl.aspx :

<body>
<form name="form1" method="get" action="MyUrl.aspx" id="form1">
<input type="hidden" name="ClickedElement" id="Messenger" />
</form>
</body>
where the the Submit() is done within a javascript function invoked at
onclick on some element.

My question is: How can I prevent form submission when MyUrl.aspx is
not available?

The javascript function is:

function Clicked(MyControl)
{
var _CellContent = document.getElementById("Messenger");
_CellContent.value = MyControl.id;
document.form1.submit();
}

Thanks for any help,

Pam

推荐答案

pa *********** @ libero.it 写道:

我的问题是:当MyUrl.aspx为

不可用时,如何阻止表单提交?
My question is: How can I prevent form submission when MyUrl.aspx is
not available?



为什么表单目标网址不可用?

为什么要编写目标网址,然后呢?或者这是完全动态的吗?


我想说如果目标

不存在,我不会阻止表单提交。不要画那个表格。为什么浪费时间填写如果它不能提交



无论如何,回答你的问题有一些可能性。一个是使用ajax来获取G / B
网址,看看服务器是否带有404

错误。如果没有,那就提交。


-

Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com


我想说,如果目标为$ b $,请不要阻止表单提交b
I would say don''t just prevent the form from submitting if the target

不存在。不要画那个表格。为什么浪费时间填写如果它不能提交

doesn''t exist. Don''t even draw the form. Why waste time fillingit out if it
can''t be submitted?



感谢Matt提供帮助。


这不是真实的用户表格。它只是一个通过动态

上下文中的asp页面将一些

信息从网页传递到服务器的设备..

Thanks Matt for helping.

It''s not a "real" user form. It''s only a device to pass some
information from a web page to a server via an asp page in a dynamic
context..


无论如何,要回答你的问题,有一些可能性。一个是使用ajax来获取G / B
网址,看看服务器是否带有404

错误。如果没有,那就提交。
Anyway, to answer your question there are a few possibilities. One would be
to use ajax to "GET" the url and see if the server comes back with a 404
error. If not, then submit.



你推荐一些我根本不熟悉的东西。我不知道我是否能够开始这样做......除非解决方案是

直截了当。


但是...在JavaScript的范围内是不是有一些简单的解决方案?

-Pam

You are recommending something I am not familiar with at all. I do not
know whether I am able to embark in that... unless the solution is
straightforward.

But... isn''t there some simple solution within the realm of javascript?
-Pam


>

-

Matt Kruse
http:// www .javascriptToolbox.com
http://www.AjaxToolbox.com


于2006年8月25日在comp.lang.javascript中写道
wrote on 25 aug 2006 in comp.lang.javascript:

但是......在JavaScript的范围内是不是有一些简单的解决方案?
But... isn''t there some simple solution within the realm of javascript?



< img

src ='' http://www.?????.com/nonexisting.asp''

style =''display:none;''

onerror =''alert (不存在。)''

onload =''aler t(有!)''

<img
src=''http://www.?????.com/nonexisting.asp''
style=''display:none;''
onerror=''alert("Does not exist.")''
onload=''alert("Does!")''


>
>



-

Evertjan。

荷兰。

(请更改我的电子邮件地址中的点数x''点数)

--
Evertjan.
The Netherlands.
(Please change the x''es to dots in my emailaddress)


这篇关于如何检查URL存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆