By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,034 Members | 979 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,034 IT Pros & Developers. It's quick & easy.

javascript created links

P: n/a
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">
var dirpath = " http://www.blah.com/images/",
image1 = "de-01.jpg";
</script>
<a href="<script language="javascript">document.write(dirpath +
image1);</script>">image1</a>
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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.
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.