Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-04-2012, 11:18 PM   PM User | #1
vivekkam
New to the CF scene

 
Join Date: Dec 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
vivekkam is an unknown quantity at this point
Question Construct URL

Hi,

I have a more than 1000 URL'S like:

localhost/foldername/trainer/7.1.0.73/frameset.html

where only the foldername changes in the URL.

Now I need a functionality on my page where there are links which has the name same as the folder name and on clicking it , it automatically replaces the name with the foldername and generates and opens the url for me.

For eg:

Suppose there is link with name : OrderEntry . So on clicking it the following URL should be generated:

localhost/OrderEntry/trainer/7.1.0.73/frameset.html

and opened in the browser. Any kind of help would be appriciated.


Thanks in advance .

Regards,

Vivek
vivekkam is offline   Reply With Quote
Old 12-04-2012, 11:44 PM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,200
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
???

And so why not simply use
Code:
<a href="localhost/OrderEntry/trainer/7.1.0.73/frameset.html ">Order Entry</a>
Presumbably, you are generating these links with some server-side code (PHP/ASP/JSP/etc.). No? So let the server side code do it.

But if you *must* do it in JavaScript, I guess you could do something like this:
Code:
<a onclick="this.href='localhost/' + this.innerHTML.replace(/\W/g,"") + '/trainer/7.1.0.73/frameset.html'; return true;">
    Order Entry
</a>
The call to replace there will remove all characters except letters, digits, and underlines from the text between the <a> and </a> tags.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Reply

Bookmarks

Tags
construction of link, java script

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:19 AM.


Advertisement
Log in to turn off these ads.