一个棘手的问题 [英] a tough question

查看:60
本文介绍了一个棘手的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨所有

我想做的是如下

开始一个功能

停止,

直到某些事件发生(也许用户点击)

然后相应地返回一些值。

或者是否可以做这些事情?

解决方案

Mr Shore< sh ********* @ gmail.comwrites:


hi all

我想做的是如下

启动功能

停止,

直到某些事件发生(也许是用户点击)

然后相应地返回一些值。

或者是否有可能做到这一点?



不,你也不想这样做。只要你做任何事情你需要从onclick处理程序做b $ b。不要和活动模特打架。

-

Joost Diepenmaat |博客: http://joost.zeekat.nl/ |工作: http://zeekat.nl/

4月14日凌晨2:07,Joost Diepenmaat< jo ... @ zeekat.nlwrote:


Mr Shore< shore.cl。 .. @ gmail.comwrites:


嗨所有

我想做的是如下

start一个函数

停止,

直到某些事件发生(可能是用户点击)

然后相应地返回一些值。

或者可以做这个吗?



不,你也不想这样做。只要你做任何事情你需要从onclick处理程序做b $ b。不要和活动模特打架。


-

Joost Diepenmaat |博客:HTTP://joost.zeekat.nl/ |工作: http://zeekat.nl/



那么您如何看待提示功能?


Mr Shore< sh ********* @ gmail.comwrites:
< blockquote class =post_quotes>


>不,你也不想这样做。只需执行你需要从onclick处理程序做的任何事情。不要与事件模型作斗争。



所以您如何看待提示功能?



这是一个黑客攻击;当

提示处于活动状态时,它会阻止用户执行任何其他操作,并且无法使用

用户编写的javascript复制该行为。 最好的你可以做的是禁用页面上的所有东西

else(例如,使用某种覆盖)。那个

/仍然/不会给你调用函数并使用返回值

机制,并且没有理由你需要它 - 事件模型是
更灵活。


你只需要


show_my_prompt(数据,函数(值){

//做有价值的东西

});


而不是


var value = prompt(data);

//做有价值的东西。


-

Joost Diepenmaat |博客: http://joost.zeekat.nl/ |工作: http://zeekat.nl/

hi all
what I want to do is as below
start a function
halt on,
until some event occurs(maybe user click)
and then return some value accordingly.
Or is it possible to do this stuff?

解决方案

Mr Shore <sh*********@gmail.comwrites:

hi all
what I want to do is as below
start a function
halt on,
until some event occurs(maybe user click)
and then return some value accordingly.
Or is it possible to do this stuff?

No, and you don''t want to do that anyway. Just do whatever it is you
need to do from the onclick handler. Don''t fight the event model.
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/


On Apr 14, 2:07 am, Joost Diepenmaat <jo...@zeekat.nlwrote:

Mr Shore <shore.cl...@gmail.comwrites:

hi all
what I want to do is as below
start a function
halt on,
until some event occurs(maybe user click)
and then return some value accordingly.
Or is it possible to do this stuff?


No, and you don''t want to do that anyway. Just do whatever it is you
need to do from the onclick handler. Don''t fight the event model.

--
Joost Diepenmaat | blog:http://joost.zeekat.nl/| work:http://zeekat.nl/

so what do you think of the prompt function?


Mr Shore <sh*********@gmail.comwrites:

>No, and you don''t want to do that anyway. Just do whatever it is you
need to do from the onclick handler. Don''t fight the event model.


so what do you think of the prompt function?

It''s a hack; it prevents the user from doing anything else while the
prompt is active, and there is no way to replicate the behaviour with
user-written javascript. The "best" you can do is to disable everything
else on the page (using some kind of overlay, for instance). That
/still/ won''t give you the "call function and use return value"
mechanism, and there is no reason you need that - the event model is
much more flexible.

You just need

show_my_prompt(data,function(value) {
// do stuff with value
});

instead of

var value = prompt(data);
// do stuff with value.

--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/


这篇关于一个棘手的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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