Tricky javascript/activex object problem

Discussion in 'Javascript' started by joebob, Jun 9, 2004.

  1. joebob

    joebob Guest

    The following script if run in Internet Explorer should
    display a thumbview of a webpage that you point it to.
    To test it, replace test.htm with a valid html file.

    The problem I'm having is that I can't get onclick to
    fire on the rendered Thumbview object. What's strange
    is that onmouseover fires. Can anyone see a way?

    <html><head><title>test</title></head>
    <body onload="Init()">
    <a onclick=alert() href="file:///C:/test.htm">
    <object id="Thumbview"
    classid="clsid:1D2B4F40-1F10-11D1-9E88-00C04FDCAB92"
    width=120 height=100 onclick=alert()>
    </object><br><br>this works
    </a>
    <script>
    function Init(){
    Thumbview.displayFile('C:\\test.htm');
    }
    </script>
    </body></html>
     
    joebob, Jun 9, 2004
    #1
    1. Advertising

  2. joebob

    Grant Wagner Guest

    joebob wrote:

    > The following script if run in Internet Explorer shoulddisplay
    > a thumbview of a webpage that you point it to.To test it,
    > replace test.htm with a valid html file. The problem I'm having
    > is that I can't get onclick tofire on the rendered Thumbview
    > object. What's strangeis that onmouseover fires. Can anyone
    > see a way?<html><head><title>test</title></head>
    > <body onload="Init()">
    > <a onclick=alert() href="file:///C:/test.htm">
    > <object id="Thumbview"
    > classid="clsid:1D2B4F40-1F10-11D1-9E88-00C04FDCAB92"
    > width=120 height=100 onclick=alert()>
    > </object><br><br>this works
    > </a>
    > <script>
    > function Init(){
    > Thumbview.displayFile('C:\\test.htm');
    > }
    > </script>
    > </body></html>


    onclick and ondblclick just aren't honored by that ActiveX
    component. You can probably get onmousedown working, you'll just
    have to set it up so that it doesn't fire repeatedly.

    Something like:

    Thumbview.onmousedown = function() {
    if (!this.mouseDownFired) {
    this.mouseDownFired = true;
    // do whatever
    return true;
    }
    return false;
    }

    --
    | Grant Wagner <>

    * Client-side Javascript and Netscape 4 DOM Reference available
    at:
    *
    http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/frames.html

    * Internet Explorer DOM Reference available at:
    *
    http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_entry.asp

    * Netscape 6/7 DOM Reference available at:
    * http://www.mozilla.org/docs/dom/domref/
    * Tips for upgrading JavaScript for Netscape 7 / Mozilla
    * http://www.mozilla.org/docs/web-developer/upgrade_2.html
     
    Grant Wagner, Jun 10, 2004
    #2
    1. Advertising

  3. joebob

    Grant Wagner Guest

    joebob wrote:

    > "Grant Wagner" <> wrote in message
    > news:...
    >
    > joebob wrote:
    >
    > > The following script if run in Internet Explorer

    > shoulddisplay
    > > a thumbview of a webpage that you point it to.To

    > test it,
    > > replace test.htm with a valid html file. The

    > problem I'm having
    > > is that I can't get onclick tofire on the rendered

    > Thumbview
    > > object. What's strangeis that onmouseover fires.

    > Can anyone
    > > see a way?<html><head><title>test</title></head>
    > > <body onload="Init()">
    > > <a onclick=alert() href="file:///C:/test.htm">
    > > <object id="Thumbview"
    > >

    > classid="clsid:1D2B4F40-1F10-11D1-9E88-00C04FDCAB92"
    > > width=120 height=100 onclick=alert()>
    > > </object><br><br>this works
    > > </a>
    > > <script>
    > > function Init(){
    > > Thumbview.displayFile('C:\\test.htm');
    > > }
    > > </script>
    > > </body></html>

    >
    > onclick and ondblclick just aren't honored by that
    > ActiveX
    > component. You can probably get onmousedown working,
    > you'll just
    > have to set it up so that it doesn't fire repeatedly.
    >
    > Something like:
    >
    > Thumbview.onmousedown = function() {
    > if (!this.mouseDownFired) {
    > this.mouseDownFired = true;
    > // do whatever
    > return true;
    > }
    > return false;
    > }
    >
    >
    > Hi Grant, I discovered that onmousedown works. Also in
    > conjunction with Overlib which is pretty cool. I haven't done
    > anything to ensure that it doesn't fire repeatedly, but I
    > haven't found that to be a problem. Can you tell me what could
    > cause that to occur? Thank you


    By "fire repeatedly" I mean that the native behavior of the
    operating system causes an event like "onmousedown" to fire over
    and over again at say, 500ms intervals because the native
    behavior of the operating system sends an event every 500ms when
    a mouse button is held down. If the onmousedown event doesn't
    fire repeatedly if you hold the mouse button down then it's fine.
    I wasn't sure if it did. Using an alert() to test made it hard to
    determine if the event was firing repeatedly.

    Good examples of "repeatedly firing" events are "onkeydown" or
    "onkeypress", which _do_ fire over and over again when you hold a
    key down. A simple example of this is (IE only):

    <form>
    <input type="text" onkeydown="putInTa(this);">
    <textarea name="output"></textarea>
    </form>
    <script type="text/javascript">
    function putInTa(inp) {
    inp.form.elements['output'].value += window.event.keyCode;
    }
    </script>

    --
    | Grant Wagner <>

    * Client-side Javascript and Netscape 4 DOM Reference available
    at:
    *
    http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/frames.html

    * Internet Explorer DOM Reference available at:
    *
    http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_entry.asp

    * Netscape 6/7 DOM Reference available at:
    * http://www.mozilla.org/docs/dom/domref/
    * Tips for upgrading JavaScript for Netscape 7 / Mozilla
    * http://www.mozilla.org/docs/web-developer/upgrade_2.html
     
    Grant Wagner, Jun 11, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    487
    George Ter-Saakov
    Mar 20, 2006
  2. Replies:
    0
    Views:
    933
  3. Replies:
    9
    Views:
    563
    CBFalconer
    Apr 25, 2006
  4. vml
    Replies:
    0
    Views:
    1,098
  5. Andy
    Replies:
    2
    Views:
    253
    kaeli
    Mar 4, 2004
Loading...

Share This Page