On Mon, 30 Aug 2004 00:35:29 -0500, John <jo**@mac.com> wrote:
Hi, I want to set a directory and an image name as a js variable and
later call those vars as and html link. I am not doing this correctly,
so I ask for help. Any advice is appreciated. Chuck
Here is a basic example.
<script type="text/javascript" language="javascript">
The type attribute makes language redundant. That, and the fact that
language is deprecated, means that you shouldn't use the language
attribute.
var dirpath = " http://www.blah.com/images/",
image1 = "de-01.jpg";
</script>
<a href="<script language="javascript">document.write(dirpath +
image1);</script>">image1</a>
You'll have to write out the entire link:
<script type="text/javascript">
document.write('<a href="' + dirpath + image1 + '">image1<\/a');
</script>
Note that the </a sequence is escaped. This should be done with all
closing tags to ensure that the browser doesn't interpret </ as the end of
the SCRIPT element.
Hope that helps,
Mike
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.