473,320 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

javascript created links

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
1 1154
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: nam | last post by:
could someone please help me with this bizarre problem - I've created a swf file at the top of my html page. The swf file (using Swish) is simply a menu of 5 links to 5 anchor points on the html...
0
by: Gowhera Hussain | last post by:
Use This for Learning Only .... Do Not Try To Act Smart HACKING WITH JAVASCRIPT Dr_aMado Sun, 11 Apr 2004 16:40:13 UTC This tutorial is an overview of how javascript can be used to bypass...
6
by: Dan Webb | last post by:
Hi All, Im currently working on ways of pacakaging javascript functions/variables/objects in a similar way to the Java package statement so that scripts can be interact with each other with the...
5
by: Stuart | last post by:
Hi We have a dynamically created javascript menu (from ASP), which is customised per user (Have already taken all the static code out into separate cached .js file) The size of the 'dynamic'...
14
by: tshad | last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an asp.net problem or a javascript problem. I have a page that was originally created from a program I found on the net...
9
by: Astra | last post by:
Hi everybody Wonder if you could help me out. I created a simple JavaScript routine to enable a user to click backwards and forwards between small news articles. This routine works fine in IE...
10
by: andreister | last post by:
He there! I've discovered that the ================================================= document.links('link_id_here').href = "something"; ================================================= is...
7
by: Kevin Newman | last post by:
I've been toying with a namespace manager, and wanted to get some input. So what do you think? if (typeof com == 'undefined') var com = {}; if (!com.unFocus) com.unFocus = {}; ...
9
by: tshad | last post by:
This is from my previous post, but a different issue. I have the following Javascript routine that opens a popup page, but doesn't seem to work if called from an asp.net button. It seems to work...
13
by: Xah Lee | last post by:
there's this one i can't figure out. I'm trying to kick out image.google.com's top frame when it goes to my page. If you go to http://images.google.com/images?q=milk+tits click on the page...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.