Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Programmatically retrieving all possible <PARAM> elements for an ActiveX Control?

    I wanted to use something like DOM's childNodes construction to retrieve all possible <PARAM> elements for an ActiveX control in Internet Explorer.

    As an example, consider embedding a copy of Windows Media Player v9.x in a web page. The classid for WMP v9.x is "6BF52A52-394A-11d3-B153-00C04F79FAA6" so something like the following will serve as a basic template:

    Code:
    <html>
    
    <body id="theBodyId">
    
    <center>
    &nbsp;<br>
    <font size="3"><b>theWMP9Id</b></font><br>
    <object id="theWMP9Id" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="500" height="300">
    </object>
    </center>
    
    </body>
    
    </html>
    Now let's add two textareas to the page, and dump both the object's innerHTML and its childNodes:

    Code:
    <html>
    
    <body id="theBodyId">
    
    <center>
    &nbsp;<br>
    <font size="3"><b>theWMP9Id</b></font><br>
    <object id="theWMP9Id" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="500" height="300">
    </object>
    <p>
    <font size="3"><b>theWMP9Id.innerHTML</b></font><br>
    <textarea id="theInnerHTMLTextArea" rows="10" cols="50"></textarea>
    <p>
    <font size="3"><b>theWMP9Id.childNodes</b></font><br>
    <textarea id="theChildNodesTextArea" rows="10" cols="50"></textarea>
    </center>
    
    </body>
    
    <script language="javascript">
    theInnerHTMLTextArea.value = theWMP9Id.innerHTML;
    
    theChildNodesString = "";
    for(var i = 0; i < theWMP9Id.childNodes.length; i++)
    {
       theChildNodesString += "theWMP9Id.childNodes[" + i + "].name = " + theWMP9Id.childNodes[i].name  + ".\n";
       theChildNodesString += "theWMP9Id.childNodes[" + i + "].value = " + theWMP9Id.childNodes[i].value  + ".\n";
       theChildNodesString += "\n";
    }
    theChildNodesTextArea.value=theChildNodesString;
    </script>
    
    </html>
    At this point we are showing 0 [zero] childNodes, but 19 different <PARAM> elements: [URL, rate, balance, currentPosition, defaultFrame, playCount, autoStart, currentMarker, invokeURLs, baseURL, volume, mute, uiMode, stretchToFit, windowlessVideo, enabled, enableContextMenu, fullScreen, SAMIStyle, SAMILang, SAMIFilename, captioningID, enableErrorDialogs, _cx, _cy].

    Now really weird stuff happens if we start to declare PARAM's explicitly. For instance, let's declare, explicitly, the three PARAM's "URL", "autoStart", and "volume":

    Code:
    <html>
    
    <body id="theBodyId">
    
    <center>
    &nbsp;<br>
    <font size="3"><b>theWMP9Id</b></font><br>
    <object id="theWMP9Id" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="500" height="300">
       <PARAM NAME="URL" VALUE="http://audio-mp3.ibiblio.org:8000/wcpe.mp3">
       <PARAM NAME="autoStart" VALUE="1">
       <PARAM NAME="volume" VALUE="75">
    </object>
    <p>
    <font size="3"><b>theWMP9Id.innerHTML</b></font><br>
    <textarea id="theInnerHTMLTextArea" rows="10" cols="50"></textarea>
    <p>
    <font size="3"><b>theWMP9Id.childNodes</b></font><br>
    <textarea id="theChildNodesTextArea" rows="10" cols="50"></textarea>
    </center>
    
    </body>
    
    <script language="javascript">
    theInnerHTMLTextArea.value = theWMP9Id.innerHTML;
    
    theChildNodesString = "";
    for(var i = 0; i < theWMP9Id.childNodes.length; i++)
    {
       theChildNodesString += "theWMP9Id.childNodes[" + i + "].name = \"" + theWMP9Id.childNodes[i].name  + "\".\n";
       theChildNodesString += "theWMP9Id.childNodes[" + i + "].value = \"" + theWMP9Id.childNodes[i].value  + "\".\n";
       theChildNodesString += "\n";
    }
    theChildNodesTextArea.value=theChildNodesString;
    </script>
    
    </html>
    After running the code, we see that childNodes now reports the three PARAM's that we declared explicitly, but continues to ignore the remaining 16.

    So childNodes gives us rather a biased view of the set of all possible PARAM's of an ActiveX control - namely, childNodes only tells us about those PARAM's that we had the foresight to define explicitly a priori.

    Now in my search for a technique that would automate the gathering of PARAM's, I tried about a gazillion things in addition to "object.childNodes", among which were "object.attributes", "object.children", "object.all", "object.behaviorUrns", and probably a bunch of other stuff that I'm too tired to remember at this point.

    Anyway, the bottom line is that I couldn't get anything to generate [programatically] a list of all possible PARAM's for an ActiveX control.

    Instead, I had to dump the control's "innerHTML" into a textarea, and copy and paste its PARAM's back into my code.

    So my question: Is there a way to do this programatically?

    Alternatively, is there some reference at msdn.microsoft.com that gives a definitive list of all possible PARAM's for each ActiveX control?

    Or is there some COM/DCOM viewer [that I could download] which would examine something like MSCOMCTL.OCX and tell me all the possible PARAM's for each ActiveX control?

    Thanks!

  • #2
    New to the CF scene
    Join Date
    Jan 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    have you tried the getElementsByTagName() function

    and when you get childNodes it think it may also pick up text nodes that are the spaces or text between tags.. so you may have to test each child for a correct nodeType before trying to ask for that childs properties

    im not sure i understand exactly what you want to get .. but this may help

    Code:
    var object_tag = document.getElementById('object_tags_id')
    var params =object_tag.getElementsByTagName('param')
    for ( var i in params ) {
      var param = params[i]
      ...
    }


  •  

    Posting Permissions

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