• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

calling a Javascript variable in anchor tag

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How about this:

[ December 19, 2006: Message edited by: Jaikiran Pai ]
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Wait for it ... wait .... wait .... NOW! Pafiffle! A perfect tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic