www.webdeveloper.com
Results 1 to 9 of 9

Thread: Url passing and redirect

Hybrid View

  1. #1
    Join Date
    May 2010
    Posts
    5

    Unhappy Url passing and redirect

    Here's the situation, am changing a website to a new address using htacces redirect 301 / NEWADRESS. This passes the browser to a redirect notice page on the new site, the page is a slightly modified version of Cool Redirect (http://www.codehouse.com/javascript/...cool_redirect/).
    When the url is passed on the page (dynamic) is also passed on, so the url looks like newsite.com/redirected.html?page2
    The question is how do I isolate that part of the url, and pass that part of the url to the redirect coding.
    Oli

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Code:
    var pageName = location.search.substring(1);
    At least 98% of internet users' DNA is identical to that of chimpanzees

  3. #3
    Join Date
    May 2010
    Posts
    5

    Thanks

    One question, how would I intergrate the "var pageName" into the location -
    <body onload='coolRedirect("http://examplesite.com/")'>
    Sorry Complete Newbie to Javascript

  4. #4
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Give an example of the from - to urls
    At least 98% of internet users' DNA is identical to that of chimpanzees

  5. #5
    Join Date
    May 2010
    Posts
    5

    Question

    This is the text on redirect.html, and it is read by an external .js file.
    <body onload='coolRedirect("http://example.com/")'>

    The user might end up on the page like
    oldsite.com/?page1
    or
    oldsite.com/index.php?page2So how do i pass the ?page onto the body onload tag.

    Thanks again

  6. #6
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Code:
    <body onload='coolRedirect("http://example.com/"+location.search.substring)'>
    At least 98% of internet users' DNA is identical to that of chimpanzees

  7. #7
    Join Date
    May 2010
    Posts
    5

    Unhappy ???

    Sorry think I must have got something wrong.
    Heres the redirect page script

    <script src="/coolRedirect.js" type="text/javascript"></script>
    <script type="text/javascript">
    var pageName = location.search.substring(1);
    </script>
    </head>
    <body onload='coolRedirect("http://example.com/"+location.search.substring)'>

    But when ever the redirect happens I get taken to a 404 error page by htaccess. And the refer shows it comes straight from the redirect page.

    Oli

  8. #8
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    1. do you want to use coolRedirect?

    2. to which page do you want to redirect to?
    At least 98% of internet users' DNA is identical to that of chimpanzees

  9. #9
    Join Date
    May 2010
    Posts
    5
    Only reason im using cool redirect is because it came up quick on google and it was easy enouth to use, and you get a nice simple countdown on the page. I dont mind changing if you know of a easier one to use.
    The page I want to link to is index.php?pageinurl, or example.com/?page1 as they both work.
    If ther is no ?page in the redirect it passes the user straight to the homepage this works.
    oli

Thread Information

Users Browsing this Thread

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

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
  •  
HTML5 Development Center



Recent Articles