dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: Calling OCX ID in Javascript globally -- error

Hybrid View

  1. #1
    Join Date
    Nov 2008
    Posts
    2

    Calling OCX ID in Javascript globally -- error

    I am using OCX for some functionality, for that I have used the <object> and want to referring the same thru the JavaScript as a global variable. Its give error "'b' is null or not an object"

    <OBJECT ID="OCXID" class="hidden" width="0" height="0"
    type="application/x-oleobject"
    CLASSID="some_Correct_ClassID" CODEBASE="MyOCX.ocx"
    </OBJECT>


    Global variables are Not Working:

    var b = window.document.getElementById("OCXID");
    //var b = document.OCXID; //this also not working fine...
    function callOCXmethod(){
    b.someOCXMethod();

    }


    Local variables are Working:

    function callOCXmethod(){
    var b = window.document.getElementById("OCXID");
    //var b = document.OCXID; //this also working fine...

    b.someOCXMethod();

    }

  2. #2
    Join Date
    Feb 2003
    Location
    Michigan, USA
    Posts
    5,774
    When defining "b", you might be called document.getElementById before the <object> tag is parsed and made a part of the document object model. In the window.onload event, or an inline SCRIPT just below the <object> tag, assign a global variable using the document.getElementById function.

  3. #3
    Join Date
    Nov 2008
    Posts
    2
    Quote Originally Posted by toicontien View Post
    When defining "b", you might be called document.getElementById before the <object> tag is parsed and made a part of the document object model. In the window.onload event, or an inline SCRIPT just below the <object> tag, assign a global variable using the document.getElementById function.
    thanks toi.....
    it's working....

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles