Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Construct URL

  1. #1
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,688
    Thanks
    80
    Thanked 4,647 Times in 4,609 Posts
    ???

    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.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •