且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何检测是否存在对话框

更新时间:2023-01-24 12:49:27

Xu,Qian写道:
Xu, Qian wrote:

是否可以检测是否有(确认或提示)对话框是否存在

Is it possible to detect whether a (confirmation or prompt) dialog is
present?



不,这样的对话框总是模态的。窗口中的脚本执行从

已经发出,直到它们被关闭为止。

No, such dialogs are always modal. Script execution in the window from
which these have been issued is halted until they have been closed.


此外,如何按OK ,取消对话框的按钮?
And furthermore, how to press OK, Cancel buttons of a dialog?



你不能。

PointedEars

-

现实主义:HTML 4.01严格

福音:XHTML 1.0严格

疯狂:XHTML 1.1 as application / xhtml + xml

- Bjoern Hoehrmann >


" Xu,Qian < qu ****** @ stud.tu-ilmenau.dewrites:
"Xu, Qian" <qu******@stud.tu-ilmenau.dewrites:

是否可以检测(确认或提示)对话框是否为

存在?
Is it possible to detect whether a (confirmation or prompt) dialog is
present?



否。在显示对话框时,页面上的脚本执行停止了
。因此,从另一个角度来看,这是微不足道的。如果您的代码

正在运行,则不会显示任何对话框。

No. While the dialog is being presented, script execution on the page
is stopped. So, from another perspective, it is trivial. If your code
is running, no dialog is being shown.


此外,如何按OK,取消对话框的按钮?
And furthermore, how to press OK, Cancel buttons of a dialog?



用户互动。

User interaction.


我正在编写一个基于javascript的测试框架。我想检测

并使用javascript关闭对话框。
I am writing a javascript based test framework. I would like to detect
and close dialog using javascript.



测试框架执行此操作的传统方式是覆盖

警报并使用模拟按下按钮的代码确认函数。 br />
使用它们的代码不需要知道,只需要预先配置

回复。


它可能不会符合您的要求,但请尝试查看Selenium

测试框架。
http://selenium-core.openqa.org/

/ L

-

Lasse Reichstein Nielsen - lr*@hotpop.com

DHTML死亡颜色:< URL:http:/ /www.infimum.dk/HTML/rasterTriangleDOM.html>

''没有判断的信仰只会降低精神神圣。''

The traditional way that test-frameworks do this is to overwrite the
alert and confirm functions with code that simulates a pressed button.
The code using them doesn''t need to know, it just gets a preconfigured
answer back.

It might not match your requirements, but try looking at the Selenium
test framework.
http://selenium-core.openqa.org/

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
''Faith without judgement merely degrades the spirit divine.''


VK写道:
VK wrote:

5月17日下午6:50,Thomas''PointedEars''Lahn< PointedE ... @ web.dewro te:
On May 17, 6:50 pm, Thomas ''PointedEars'' Lahn <PointedE...@web.dewrote:

> Xu,Qian写道:
>Xu, Qian wrote:

>>是否有可能检测到是否存在(确认或提示)对话框?
>>Is it possible to detect whether a (confirmation or prompt) dialog is
present?


不,这样的对话框总是模态的。
窗口中的脚本执行已停止,直到它们被关闭。

No, such dialogs are always modal. Script execution in the window from
which these have been issued is halted until they have been closed.



一个危险的错误


A dangerous mistake



我的措辞很不精确。

My wording was just imprecise.


我曾经遇到过大麻烦。
I once had big troubles with.



没有冒犯意味着,但考虑到你之前所展示的误解的性质和数量,你会想知道你是如何写作的完全没有代码。

No offense meant, but given the nature and number of misconceptions you have
demonstrated before, one wonders how you are able to write working code at all.


在基于Gecko的浏览器中,包括Firefox内置对话框只是模态的,只需要当前执行上下文的

In Gecko-based browsers including Firefox build-in dialogs are modal only
withing the current execution context.



我知道这一点。

I was aware of that.


[示例代码]
[example code]



如果省略所有不必要的部分,你的例子会短得多。

PointedEars

-

使用用于创建网站的任何版本的Microsoft Frontpage。

(这不会阻止人们查看您的来源,但没有人

会想要窃取它。)

- 来自< http://www.vortex-webdesign.com/help/hidesource.htm>

Your examples could be much shorter if you omitted all the unnecessary parts.
PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won''t prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>