This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

calling a Javascript variable in anchor tag

 
sundar sankaran
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to know how to call a Javascript variable in html a href tag. Here is my snapshot of my requirement:
<html>
<head>
<script type="text/JavaScript">
var path="/u03/abc/app/Learning/";
</head>
</script>
<body>
<a href=path variable to come here"TC1011018C.html" target="rframe">sometext1 </a> <br>

<a href="TC2062021C.html" target="rframe">sometext2</a> <br>

<a href="TC3043046C.html" target="rframe">sometext3</a> <br>

</body>
</html>
My path variable has to come before href html link(TC1011018C.html). I googled several site. How it can be acheived?? Please help me.

Regards,
Sundar
 
sundar sankaran
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In addition to the above thread .Here I am using frames(left and right)Here the all the links will be there in left frame. On clicking the link, the correponding html file will be open in right frame.
 
vijaya bharath
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

can't you write the anchor tag in javascript only.If so can you please try this.
 
sundar sankaran
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bharath,
This solution I tried, but is very tedious work. I cannot embed some 50 a href tags to document.write. Please give alternate solution to call the javascript variable in a href.
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about this:

[ December 19, 2006: Message edited by: Jaikiran Pai ]
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
AND can I ask why you are relying on JavaScript tp do this when you have a reliable thing called the serverside language to do it. What if the user clicks on a link before the page loads? Looks like they will get an error in the right frame.

Eric
 
sundar sankaran
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jaikiran,
I have tried your thing, but I am getting fullpath like this see the bolded one:
eg:
abc/jsp/openhyperlink.jsp?fileName=/u03/app/Learning/http://localhost:8080/abc/jsp/TC1011018C.html
I must get like this "
abc/jsp/openhyperlink.jsp?fileName=/u03/app/Learning/TC1011018C.html

Please let me know the solution for this.

To answer Eric question, Here my requirement is we need to dump lot of elearning courses in a separate content server. The elearning courses will have many html, swf, img files etc. I calling this html files via server side script ie from Jsp. But I cannot write any Jsp code in the content server folder and call it in Jsp or servlet. Did I answer your question.
 
sundar sankaran
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Has anyone have solution for this. I am also struck with other code that how to call a variable in img src tag:
eg:
<html>
<head>
<script>
var k="\app\abc\adi\"
</script>

<body>
<img src =how to call the k variable"some.gif">
</body>
</html>
I am totaly struck. It is urgent requirement. Please give a solution.

regards,
Sundar
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic