Page 1 of 2 12 LastLast
Results 1 to 15 of 30

Thread: Redirects

  1. #1
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Redirects

    I know how to use META tag to achieve a redirect.

    Is there a way to include more than one redirect in a single HTML file so
    that the incoming link could choose the META to be used?
    That would preferable to using a separate file for each META.

    In effect, single META file would be a gatekeeper, allowing me to change the
    internal structure of a web site, but maintain a constant external link.
    Those links would be changed only in exceptional circumstances.

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Redirects

    You could easily do this one of two ways:
    1) Javascript in the OnLoad event of the Body element
    2) Server-side code (like ASP or ASP.NET) in conjunction with the Response.Redirect() method

    I'm not aware of a way to *easily* use a dynamic META refresh tag...

    Also, keep in mind that the META tag and Javascript are both dependent on client-side settings. The Server-side method is completely independent of any client-side settings.

  3. #3
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Redirects

    My ISP does not permit us to do server-side stuff.

    Can Javascript parse the incoming URL and ten figure out where to go?

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Redirects

    To change the page displayed in the current window with JavaScript, look up location in your JavaScript reference.

    To see how to process a command-line parameter using JavaScript triggered by an onload event, see <post#=413905>post 413905</post#>.

  5. #5
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Redirects

    Thanx.

    I pulled my 3 Javascript books out last night from under table legs.

    I'll take a look today.

  6. #6
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Redirects

    I lied!

    A few minutes ago, I learned that my ISP does allow some server side scripts in shtml files.
    So, I guess I need to find out how to do that.
    I would prefer server-independent scripts.
    Is there such a critter?

  7. #7
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Redirects

    > server-independent scripts

    You will generally find that Perl and PHP are supported by both *nix (Linux and Unix) as well as the Microsoft platforms. If you use ASP (or ASP.NET) you're pretty much stuck with Microsoft.

  8. #8
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Redirects

    If I have a choice between using client side Javascript and server side PHP or SSI, doesn't it make sense to stick with Javascript?

  9. #9
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Redirects

    No. I would place a higher trust on server-side coding in this case because you have no guarantee that your viewers will have Javascript enabled, which will cause their experience on your site to be less than desired. Server-side scripting is totally reliable for users of any supported browser (with or without Javascript).

    Also, server-side coding lets you keep your code private - users only see the resulting HTML. Javascript, on the other hand, is sent completely to the client, allowing them to see (and *borrow*) all of your code.

  10. #10
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Redirects

    Going back and reading your initial post, I don't think you can create a single file to handle requests for deleted pages, unless it's a custom 404 handler that receives all requests for missing or nonexistent pages. Ask your ISP about your script language options for a custom 404 page to make sure you can hook into that function. Otherwise, you'll still need individual pages for each "old" URL you decide to abandon.

  11. #11
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Redirects

    Initially, I'm gonna go the javascript route as I already have 3 javascript books and a copy of the ECMAScript standard.
    Otherwise, I gotta find books for SSI and PHP.

    The code I'll be using, for the most part, is not complex.
    There's one thing I have not yet figured out, but I'll mention that in another posting in this thread.

  12. #12
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Redirects

    I would prefer the equivalent of a 404 page. I'll ask my ISP if they have that capability.

    Otherwise, I had been thinking of the following for javascript.
    I would tell folkes that a link is http://www.standards.com/links.html#SomeBookmark, where the bookmark would vary as needed.
    In effect, links.html would just a list of bookmarks, to make the doc valid HTML.

    I am ASSuME-ing that onload.target returns the string for the URL used to get to the page.
    If not, I would have to find some other way to get that URL.

    I would then use that string (or just the bookmark portion) to determine how to set location.href.
    I hope javascript has a Select ... Case, otherwise, ...!

  13. #13
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Redirects

    onload.target doesn't sound familiar, but location.href will take you a long way.

    The JavaScript equivalent of Select...Case...End Select is Switch...Case; but it isn't quite the same because you have to "manually" exit the switch structure (using break at the end of each case, unlike VB.

  14. #14
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Redirects

    Another thought: as an alternative to using Switch...Case, you could define arrays of URL keywords and corresponding page addresses and store these in a separate .js file which you access with a JavaScript source include. In your main page, you'd have a lightweight for loop. This could reduce code maintenance, but it's less transparent than having it all in one structure.

  15. #15
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Redirects

    It is my understanding that target is a property of onload and that it returns the URL used to get to the current document.

    location.href will redirect to the actual doc the user wants to see.

    I guess the designers of Javascript were fans of the TV show Gimmee a Break!

Page 1 of 2 12 LastLast

Posting Permissions

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