<head>
<script type="javascript">
var fred = 'path/to/image.jpg';
</script>
</head>
<body>
<script type="text/javascript">
document.write('<img src="' + fred + '" />');
</script>
</body>
Of course if the user doesn't have client-side JavaScript enabled, they get
nothing. I better alternative might be:
<head>
<script type="javascript">
var fred = 'path/to/image.jpg';
</script>
</head>
<body onload="
if (document.images && document.images['myImage']) {
document.images['myImage'].src = fred;
}
">
<img name="myImage" src="/path/to/dummyImage.jpg" />
</body>
"Ross M. Greenberg" wrote:
[color=blue]
> The variable "fred" is defined in the HEAD, and as such is static for the life
> of the rendering.
>
> I want a tag such as <IMG src=fred...>, but I simply don't know the proper
> syntax for such.
>
> Newbie question I know, but then I are one...
>
> Thanks!
>
> Ross
> "Lasse Reichstein Nielsen" <lrn@hotpop.com> wrote in message
> news:3cci5uf3.fsf@hotpop.com...[color=green]
> > "Ross M. Greenberg" <greenber@catskill.net> writes:
> >[color=darkred]
> > > If I have a variable named 'fred', the contents looking like this:
> > > '/gif/picture1.gif', how can I display that image?[/color]
> >
> > Where?
> >
> > You can do this:
> > ---
> > var img = new Image();
> > img.src=fred;
> > document.body.appendChild(img);
> > ---
> > but that displays the image at the end of the document.
> >
> > /L
> > --
> > Lasse Reichstein Nielsen -
lrn@hotpop.com
> > DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
> > 'Faith without judgement merely degrades the spirit divine.'[/color][/color]
--
| Grant Wagner <gwagner@agricoreunited.com>
* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html
* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp
* Netscape 6/7 DOM Reference available at:
*
http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
*
http://www.mozilla.org/docs/web-deve...upgrade_2.html