Re: accessing javascript variables in HTML
- From: Laurent Bugnion <galasoft-lb@xxxxxxxxxx>
- Date: Sat, 26 Aug 2006 23:32:08 +0200
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
.
- Follow-Ups:
- References:
- accessing javascript variables in HTML
- From: ksr
- accessing javascript variables in HTML
- Prev by Date: Re: make array1 array2 inner a cicle for
- Next by Date: Re: make array1 array2 inner a cicle for
- Previous by thread: accessing javascript variables in HTML
- Next by thread: Re: accessing javascript variables in HTML
- Index(es):
Relevant Pages
|
Loading