2

I have the following code:

document.getElementById("launcherDiv").innerHTML = 
"<object id='launcher' 
classid='CLSID:17E88883-3488-46B8-BE4D-30568888855' 
codebase='Helper.CAB#version=8,8,8,88'>
</object>";

Let say the download/installing failed,
How can I know this? depending of it that I can't know how much time it supposed to take..

If I will check in a loop how can I know when to end?

previously I used to define the tag inside the HTML and it waiting until the installation finished or failed.
But now I need delay loading of this ActiveX so I can't use this

Can anyone help me?


How do I get the mouse position in FireFox?

This code works in Google Chrome and IE but not in FireFox.

function drawChildren(names) {
    var c = document.getElementById("myCanvas");
    var ctx = c.getContext("2d");       
    var ctxcolor = "#000000";

    if(listeners < 1){
        c.addEventListener("click", getPosition, false);
        listeners = 1;
    } // At the click function "getPosition" is executed
}

function getPosition(event) {

    if ( event.offsetX == null ) { // Firefox
        clickedX = event.layerX;
        clickedY = event.layerY;
    } else {                       // Other browsers
        clickedX = event.offsetX;
        clickedY = event.offsetY;
    }

    checkCoordinates(clickedX, clickedY);  
}
4

4 回答 4

4

如果对象标签加载失败,那么它将在标签之间呈现内部 HTML。例如

<object data="my/file/path.pdf">Object not supported</object>

如果对象失败,那么它将显示内部文本,即“对象不支持”

于 2014-12-05T07:36:21.613 回答
0

I know this is a old post but I was trying something like this my self. In the object tag you can do something else inside it. For example I was making a music site and If the custom player didnt load I wanted the audio tag to take over.

example:

<object>
    <load customplayer> <!--==If this fails do the next line ==-->
          <audio>
                load song
          </audio>
</object>
于 2013-06-22T13:12:24.753 回答
0

也许这有帮助:

    var iv = setInterval(function () {
    if (document.all["launcher"].readyState == 4) {
    clearInterval(iv)
    alert("Object loaded")
    }
    }, 100);

它所做的是设置一个间隔,每 100 秒检查一次就绪状态,如果对象已加载,它会发出警报。

于 2012-06-28T11:24:11.873 回答
0

成功加载嵌入内容的对象中的(第一个)锚点与未成功加载的对象中的后备内容(第一个)锚点之间的唯一区别是元素的尺寸。因此,您所要做的就是确定您用于后备的元素的策略(这很可能是一个锚元素,尽管有些人可能仍然支持 Flash 作为后备内容),然后定位该元素并在示例中获取它;如果高度大于 0,则对象元素未成功加载height

var o = document.getElementsByTagName('object');
console.log(o[0].getElementsByTagName('a')[0].getBoundingClientRect().height);
于 2015-05-27T19:34:11.840 回答