Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. error 404 rerouting

error 404 rerouting

Scheduled Pinned Locked Moved Web Development
javascripthtmlwindows-adminhelpquestion
15 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W wildfiction

    Any resources that you could refer me to where I'd find the java script syntax to do that. I'm only acquintanted with java script in browsers and haven't been fully introduced so I'm not sure how I would retrieve the value of the page which cause the 404.

    M Offline
    M Offline
    Michael Flanakin
    wrote on last edited by
    #4

    This should be a good start: http://www.w3schools.com/js/default.asp[^]. http://www.w3schools.com[^] is a great resource. In order to give you any more help, I'd have to know the exact URL the page receives when a 404 happens. I'm assuming you get a querystring variable that specifies the requested page that wasn't found. If not, then you're kinda SOL. Michael Flanakin Web Log

    W 1 Reply Last reply
    0
    • M Michael Flanakin

      This should be a good start: http://www.w3schools.com/js/default.asp[^]. http://www.w3schools.com[^] is a great resource. In order to give you any more help, I'd have to know the exact URL the page receives when a 404 happens. I'm assuming you get a querystring variable that specifies the requested page that wasn't found. If not, then you're kinda SOL. Michael Flanakin Web Log

      W Offline
      W Offline
      wildfiction
      wrote on last edited by
      #5

      Thanks for the links Michael. No, there is no querystring variable. I was under the impression that you could pick up the referring page (the missing page that generates the 404) from a java variable?

      M 1 Reply Last reply
      0
      • W wildfiction

        Thanks for the links Michael. No, there is no querystring variable. I was under the impression that you could pick up the referring page (the missing page that generates the 404) from a java variable?

        M Offline
        M Offline
        Michael Flanakin
        wrote on last edited by
        #6

        I don't think it'll work because it's not a redirect. You can try it. That'd be document.referrer, using JavaScript. At least, I think that's right. I know ASP calls it HttpReferer (only one "r"). Who knows why they're different. You can try this, but I'm pretty sure it won't work. What happens is IIS looks for the file before sending the request to the page. If it's not there, then it checks to see how 404 messages should be handled. Not having the invalid URL makes it pretty much pointless, as far as I know. Well, I guess there's only one last hope (assuming the JavaScript referrer doesn't work): does your URL change when you get redirected to the 404 page? If not, then that's your saving grace. Just grab the window.location.href property. I'm assuming it does change, but I'll keep my fingers crossed for you. Michael Flanakin Web Log

        W 1 Reply Last reply
        0
        • M Michael Flanakin

          I don't think it'll work because it's not a redirect. You can try it. That'd be document.referrer, using JavaScript. At least, I think that's right. I know ASP calls it HttpReferer (only one "r"). Who knows why they're different. You can try this, but I'm pretty sure it won't work. What happens is IIS looks for the file before sending the request to the page. If it's not there, then it checks to see how 404 messages should be handled. Not having the invalid URL makes it pretty much pointless, as far as I know. Well, I guess there's only one last hope (assuming the JavaScript referrer doesn't work): does your URL change when you get redirected to the 404 page? If not, then that's your saving grace. Just grab the window.location.href property. I'm assuming it does change, but I'll keep my fingers crossed for you. Michael Flanakin Web Log

          W Offline
          W Offline
          wildfiction
          wrote on last edited by
          #7

          Michael: You're a genuis - a millions thanks for your help. This works and does just what I want: var lostPage = window.location.href; window.location = "http://www.xxxxxx.com/pnf.aspx?lost=" + lostPage; Once I'm at the aspx page it becomes much easier to process and redirect the error. Thanks again!!

          W M 2 Replies Last reply
          0
          • W wildfiction

            Michael: You're a genuis - a millions thanks for your help. This works and does just what I want: var lostPage = window.location.href; window.location = "http://www.xxxxxx.com/pnf.aspx?lost=" + lostPage; Once I'm at the aspx page it becomes much easier to process and redirect the error. Thanks again!!

            W Offline
            W Offline
            wildfiction
            wrote on last edited by
            #8

            I'm trying to improve on this and also get the page which had the link to the missing page. I'm trying to use the history object: document.write("window.history.length=" + window.history.length + " "); etc... Problem is I can't work out how to access element n out of the history array. I tried window.history[1] etc. but that doesn't work and the w3 schools doesn't seem to have any more info on it. Anybody know the syntax for this? -- modified at 0:12 Friday 30th December, 2005

            M 1 Reply Last reply
            0
            • W wildfiction

              Michael: You're a genuis - a millions thanks for your help. This works and does just what I want: var lostPage = window.location.href; window.location = "http://www.xxxxxx.com/pnf.aspx?lost=" + lostPage; Once I'm at the aspx page it becomes much easier to process and redirect the error. Thanks again!!

              M Offline
              M Offline
              Michael Flanakin
              wrote on last edited by
              #9

              By the way, I was kind of wrong. You should set window.location.href, not just windows.location. It's been a while :-P I think it might work either way in IE, but specifying the href property is the correct way. Michael Flanakin Web Log

              W 1 Reply Last reply
              0
              • M Michael Flanakin

                By the way, I was kind of wrong. You should set window.location.href, not just windows.location. It's been a while :-P I think it might work either way in IE, but specifying the href property is the correct way. Michael Flanakin Web Log

                W Offline
                W Offline
                wildfiction
                wrote on last edited by
                #10

                Thanks Michael - I'll correct that. Any ideas about the history object?

                1 Reply Last reply
                0
                • W wildfiction

                  I'm trying to improve on this and also get the page which had the link to the missing page. I'm trying to use the history object: document.write("window.history.length=" + window.history.length + " "); etc... Problem is I can't work out how to access element n out of the history array. I tried window.history[1] etc. but that doesn't work and the w3 schools doesn't seem to have any more info on it. Anybody know the syntax for this? -- modified at 0:12 Friday 30th December, 2005

                  M Offline
                  M Offline
                  Michael Flanakin
                  wrote on last edited by
                  #11

                  Due to privacy issues, you cannot see the history. The only way to access this is to use the window.history.back() method. Yeah, it kind of sucks, but think about what it would mean if sites could see where you've been. Michael Flanakin Web Log

                  W 1 Reply Last reply
                  0
                  • M Michael Flanakin

                    Due to privacy issues, you cannot see the history. The only way to access this is to use the window.history.back() method. Yeah, it kind of sucks, but think about what it would mean if sites could see where you've been. Michael Flanakin Web Log

                    W Offline
                    W Offline
                    wildfiction
                    wrote on last edited by
                    #12

                    That makes sense. But I was under the impression that you could at least get to the page that linked to this one. Otherwise your log files wouldn't be able to tell you where your referrals came from right?

                    M 1 Reply Last reply
                    0
                    • W wildfiction

                      That makes sense. But I was under the impression that you could at least get to the page that linked to this one. Otherwise your log files wouldn't be able to tell you where your referrals came from right?

                      M Offline
                      M Offline
                      Michael Flanakin
                      wrote on last edited by
                      #13

                      Did you try document.referrer? Michael Flanakin Web Log

                      W 1 Reply Last reply
                      0
                      • M Michael Flanakin

                        Did you try document.referrer? Michael Flanakin Web Log

                        W Offline
                        W Offline
                        wildfiction
                        wrote on last edited by
                        #14

                        I thought I had tried document.referrer last week and couldn't get it to work but just tried it again now and it seems to work okay. Thanks again!! Problem solved and a solution found thanks to all your help :)

                        M 1 Reply Last reply
                        0
                        • W wildfiction

                          I thought I had tried document.referrer last week and couldn't get it to work but just tried it again now and it seems to work okay. Thanks again!! Problem solved and a solution found thanks to all your help :)

                          M Offline
                          M Offline
                          Michael Flanakin
                          wrote on last edited by
                          #15

                          Not a problem. Note that you won't get a referring page if you go directly to the page. That only exists if you click a link to browse to a page. Michael Flanakin Web Log

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups