www.webdeveloper.com
Results 1 to 4 of 4

Thread: Knowing the url of the browser

  1. #1
    Join Date
    Sep 2008
    Posts
    6

    Knowing the url of the browser

    Hi there, I would like to know how to get the browser url in order to send the browser to contact page in english or spanish. I write some code is AS3 so I write a Pseudo JS code cause Im tottally lost, I really would like some hints on this one.

    Heres the thing, if you are surfing my site you will be surfing in english or in spanish, like this:

    http://www.mysite.com/es/republica-dominicana.html
    http://www.mysite.com/en/dominican-republic.html

    I would like to shorten the adress till the final "/" backwards,
    I mean, I need to know if the person is surfing in english or spanish, so they can go to their proper language contact form.

    Pseudo code

    function urlLanguage
    {
    if('http://www.mysite.com/en')
    {
    url = 'http://www.mysite.com/en/contactus.html'
    }else{
    url = 'http://www.mysite.com/en/contactus.html'
    }

    window.open ('url', '_self')

    Thanks in advanse for any information about this.
    Greetings.

  2. #2
    Join Date
    Sep 2008
    Posts
    6
    The else line would be:

    else{
    url = 'http://www.mysite.com/es/contactenos.html'
    }

    My bad. Greetings.

  3. #3
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    Well, it can be done, but it would be a lot of work. What would be better than getting the URL (which can be accessed with document.URL) and looking for either "en" or "es", would be to use a cookie that defaults to one or the other, give the user a link that will switch back and forth between the two, and every time that link is clicked set the value of the cookie to that language.
    |||||
    o . Q
    ___ "You live and you learn; or you don't live long." - Lazarus Long

    ^_^

  4. #4
    Join Date
    May 2005
    Location
    Dirty Jersey
    Posts
    1,400
    use "window.location.href" to find the URL

    do something like If(window.location.href.indexOf("siteA") > -1){//send to formA}

    etc

    1. If you reply to my post, and your reply would then appear directly beneath my post, DON'T QUOTE MY ENTIRE POST!!! IT'S REDUNTANT!!! IT'S ASININE!!!! IT'S REDUNDANTLY ASININE!!!!! DON'T DO IT!!!!
    2. jQuery extends the functionality of JavaScript. If you don't know JavaScript, give up on that jQuery script and learn JavaScript. You'll save yourself a lot of frustration, I promise.
    3. Use the [code][/code] tags. Otherwise, you may be left wondering why no one responded to your eyesore of a thread.


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles