Click to See Complete Forum and Search --> : Javascript variables in html tags


Patrick Spence
03-29-2000, 05:16 PM
Consider the following...

<SCRIPT LANGUAGE="Javascript">

var sFontFace = "arial narrow";
var sFontSize = "8";

</SCRIPT>

<FONT FACE=&{sFontFace}; SIZE=&{sFontSize};>
Hello World!
</FONT>

The above prints Hello World! in some other font other than "arial narrow".
Ideas anyone? This "technique" was referenced on the Netscape site, but
doesn't appear to work on MSIE. Is anyone *really* surprised about this? The
goal here is to make a single assignment to variables that will contain the
font faces and point size, then reference those variables w/in the html,
making maintenance easier.

Pushpa
03-30-2000, 08:02 PM
Hi Patrick,

I have found that encapsulating your font preferences in Style sheets(CSS)
makes life easier.
With CSS, u can define a Class & then include it in ur HTML.
For eg:-
<html>
<head>
<LINK REL=STYLESHEET TYPE="text/css" SRC="/includes/Styles.css">
<style type="text/css">
<!--
@import "Styles.css";
.GreenBg
{
BACKGROUND-COLOR: #e0e0c2;
COLOR: black;
FONT-FAMILY: Verdana, Arial;
FONT-SIZE: 8pt
}

-->
</style>
</head>
<body>
U can make ur text look green :)
<table>
<tr>
<td Class="GreenBg">
Hello World!!!
</td>
</tr>
</table>

</body>
</html>


"Patrick Spence" <patrick@pkspence.com> wrote:
>Consider the following...
>
><SCRIPT LANGUAGE="Javascript">
>
> var sFontFace = "arial narrow";
> var sFontSize = "8";
>
></SCRIPT>
>
><FONT FACE=&{sFontFace}; SIZE=&{sFontSize};>
> Hello World!
></FONT>
>
>The above prints Hello World! in some other font other than "arial narrow".
>Ideas anyone? This "technique" was referenced on the Netscape site, but
>doesn't appear to work on MSIE. Is anyone *really* surprised about this?
The
>goal here is to make a single assignment to variables that will contain
the
>font faces and point size, then reference those variables w/in the html,
>making maintenance easier.
>
>