dcsimg
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.

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

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

    etc

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