Re: accessing javascript variables in HTML



Hi,

ksr wrote:
Hello,

I have a HTML page, which loads an activeX control in the browser.
In the <HEAD> section, I have javascript similar to the following,

<SCRIPT language="JavaScript">
var Index = "";
// do some processing which sets a value to variable Index
</SCRIPT>

In the <BODY> section, I am downloading the cab file, which is an
activeX control, so the code is,

<BODY TEXT="#000000" BGCOLOR="#FFFFFF"..........>
<OBJECT ID="objID" CLASSID=...."CODEBASE="..>
<param name="name" value=..>.

</OBJECT>
</BODY>
</HTML>

In the param name=value pair, I want to assign the variable Index to
value. Just by doing value=Page, it does not work. Could someone
suggest how I can access javascript variable here?

Thankyou.

HTML is a static language, so it cannot access JavaScript variables. It
has to go the other way round, with JavaScript setting the HTML value.
Thankfully, with DOM Level 2 it has become much easier to do this kind
of things.

My suggestion is to set an ID on your PARAM node, and then use
document.getElementById to get it.

<param name="name" id="name" value="...">

Note that the ID must be unique throughout the whole HTML document.

Then:

var nParam = document.getElementById( "name" );
if ( nParam != null )
{
nParam.setAttribute( "value", Index );
}


HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
.



Relevant Pages

  • Javascript calling method from ActiveX control FAILS!
    ... I'm using an HTML controlwhich embeds in ... In my HTML Popdown Menu I'm calling a Javascript for every onchange. ... need to do anything extra in Javascript or in the my ActiveX control ...
    (microsoft.public.inetsdk.programming.webbrowser_ctl)
  • accessing javascript variables in HTML
    ... which loads an activeX control in the browser. ... In the <HEAD> section, I have javascript similar to the following, ... I want to assign the variable Index to ...
    (comp.lang.javascript)
  • Re: Javascript calling method from ActiveX control FAILS!
    ... Parameter for getScriptValue in ActiveX control must be VARIANT type. ... > I'm using an HTML controlwhich embeds in ... > In my HTML Popdown Menu I'm calling a Javascript for every onchange. ...
    (microsoft.public.inetsdk.programming.webbrowser_ctl)
  • Re: asp.net serial port
    ... You can do this with an ActiveX control (NETComm.ocx from my homepage, ... and JavaScript to access the control from code behind on the HTML ...
    (microsoft.public.dotnet.languages.vb)
  • Security holes in Hotmail, Yahoo, and other webmails
    ... Most webmails services and applications have huge security holes on the ... execution of malicious javascript and HTML code ... some parts of the user's mailbox, without use of javascript. ... Cross-site scripting vulnerabilities on the yahoo.com domain was reported ...
    (Vuln-Dev)

Loading