4

I've noticed that there are 2 ways we can create ActiveX object in JavaScript, one is by embedding:

<object id="TestControl" classid="clsid:xxx-xx-xx-xx"></object>

and then later on obtain object using DOM:

var myControl = document.getElementById('TestControl');

Another way is to create instance of ActiveXObject:

var myControl2 = new ActiveXObject('Test.TestControl');

What exactly is different from ActiveX object perspective? Is one approach better then the other? Are there any differences in performance?

Thanks.


java, calling a method after a modifiable delay

I'd like to ask you about the best solution/idea how to solve a following situation. I'm developing an Android app which on one of screens has a set of buttons. After clicking on any of them a kind of config is posted to the server over http. To prevent multiple clicks one by one which could result in concurrency problems I decided that after each click on a particular button there'll be a waiting interval of 30 seconds before a config is sent to the server. If another click on the same button happens before this 30 seconds are exceeded, then the execution of method is delayed for another 30 seconds - as long as no new click is performed, then the config will be sent.

I need an idea of an algorithm which would implement the mechanism above. What I know is that I don't want to start a separate thread for each click (too heavy for my app). A potential idea is to make a queue of events and send them in a loop but idea of a running endless loop in a thread (or Handler) also isn't my favourite.

Maybe there's a kind of mechanism in Android or J2SE in general, that allows to schedule an execution of method to a given time in the future but still be able to postopone execution for some additional time before 30sec rolled out.

thanks in advance!

4

1 回答 1

5

两者几乎是等价的。

<object>符号是官方 HTML ;var myControl2 = new ActiveXObject('Test.TestControl');只能在 JScript 或 ASP 等脚本语言中使用;它不能直接用于 HTML。

此外:“对象”符号采用类 ID:您所需要的只是安装在系统上(或可通过 Internet 安装)的 ActiveX 对象。您提供的 Javascript 示例有一个 PROGID ...它要求 1) ActiveX 对象已经安装,并且 2) ActiveX 对象必须有一个 PROGID(ActiveX 是可选的,不是必需的)。

于 2012-12-15T00:14:56.717 回答