HTML code for automatic history.back reload

  • HKt0p5
  • Graduate
  • Graduate
  • User avatar
  • Joined: Mar 19, 2008
  • Posts: 134
  • Loc: Bulgaria
  • Status: Offline

Post July 4th, 2008, 11:43 pm

Is there an HTML code that can make my error 404 page to automatically reload "back to previous page"?
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post July 4th, 2008, 11:43 pm

  • casablanca
  • Proficient
  • Proficient
  • User avatar
  • Joined: May 29, 2007
  • Posts: 481
  • Status: Offline

Post July 5th, 2008, 1:53 am

Just put the JavaScript in your 404 page, like this: (of course, this assumes that you have access to your server's error page configuration)
Code: [ Select ]
<html>
 
<head>
<script type="text/javascript">
history.back();
</script>
</head>
 
<body>
404 error message and other stuff here...
</body>
 
</html>
  1. <html>
  2.  
  3. <head>
  4. <script type="text/javascript">
  5. history.back();
  6. </script>
  7. </head>
  8.  
  9. <body>
  10. 404 error message and other stuff here...
  11. </body>
  12.  
  13. </html>
No Strings Attached: A JavaScript graphics demo.
  • Fabinator
  • Proficient
  • Proficient
  • No Avatar
  • Joined: May 05, 2007
  • Posts: 467
  • Status: Offline

Post July 5th, 2008, 3:17 am

This article explains how to make a custom 404 page, and just put casablanca's code in it ;)
  • HKt0p5
  • Graduate
  • Graduate
  • User avatar
  • Joined: Mar 19, 2008
  • Posts: 134
  • Loc: Bulgaria
  • Status: Offline

Post July 5th, 2008, 3:44 am

Yes, I have accsess to customizing error pages.
Casablanka's code is pretty neat, but there is one thing I wanted to ask, is there and what exactly is the setting for how many seconds it stays on before preloading?

Thanks guys, I'll see what I can do but maybe I should stick to the regular history.back button thingy.
  • casablanca
  • Proficient
  • Proficient
  • User avatar
  • Joined: May 29, 2007
  • Posts: 481
  • Status: Offline

Post July 5th, 2008, 6:06 am

HKt0p5 wrote:
is there and what exactly is the setting for how many seconds it stays on before preloading?

You mean it should wait for a few seconds before going back? This should do that:
Code: [ Select ]
<script type="text/javascript">
window.setTimeout('history.back();', 5000); // waits 5 seconds before going back
</script>
  1. <script type="text/javascript">
  2. window.setTimeout('history.back();', 5000); // waits 5 seconds before going back
  3. </script>
No Strings Attached: A JavaScript graphics demo.
  • HKt0p5
  • Graduate
  • Graduate
  • User avatar
  • Joined: Mar 19, 2008
  • Posts: 134
  • Loc: Bulgaria
  • Status: Offline

Post July 5th, 2008, 6:25 am

Okay, thanks.
But.. I think I have a very serious problem right now. I accidentally replaced the original .htaccess file with an experimental one and.. well, can someone please tell me what was supposedly contained in the original one so I can make it again and upload it? What was the original code in the original .htaccess file >_____<
  • casablanca
  • Proficient
  • Proficient
  • User avatar
  • Joined: May 29, 2007
  • Posts: 481
  • Status: Offline

Post July 5th, 2008, 10:42 pm

.htaccess files can contain just about anything - you really can't say until some part of your website breaks down. If you haven't changed the file previously, it's probably the default - you might find a copy in another directory or you can ask your web host.
No Strings Attached: A JavaScript graphics demo.
  • HKt0p5
  • Graduate
  • Graduate
  • User avatar
  • Joined: Mar 19, 2008
  • Posts: 134
  • Loc: Bulgaria
  • Status: Offline

Post July 5th, 2008, 10:49 pm

Yes, so I did. It turns out that.. it's.. BLANK!
And I realized that my mistake was that I was editing it with Notepad supposedly clearing all the text in it in my PC and then uploading it but my site still didn't fix - but when I opened it with the file manager editor, it turned out there were two squares(?) in it. After I deleted them, everything went to normal.

It's supposed to be an Apache server but it acts weird. When I did the ErrorDocument 404 /404.html in notepad and uploaded it, it didn't work. But when I edited it with the file manager editor, now it all works well.
  • Bogey
  • Bogey
  • Genius
  • User avatar
  • Joined: Jul 14, 2005
  • Posts: 8212
  • Loc: USA
  • Status: Offline

Post July 5th, 2008, 11:30 pm

those two squares were probably spaces ( \n\n ) or tabs ( \r\r ) or some other special case characters.
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Joined: Sep 22, 2003
  • Posts: 6134
  • Loc: Seattle, WA
  • Status: Offline

Post July 6th, 2008, 10:33 pm

\r isn't a tab..

HKt0p5, the funky characters you saw were probably just line endings that Notepad isn't used to. I hate using Notepad for just about anything because it never knows how to properly display files with UNIX or Mac line endings.
The Beer Monocle. Classy.
  • Bogey
  • Bogey
  • Genius
  • User avatar
  • Joined: Jul 14, 2005
  • Posts: 8212
  • Loc: USA
  • Status: Offline

Post July 6th, 2008, 11:00 pm

\t is a tab correct?
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • casablanca
  • Proficient
  • Proficient
  • User avatar
  • Joined: May 29, 2007
  • Posts: 481
  • Status: Offline

Post July 7th, 2008, 7:25 am

Yes, \t is a tab and \r is a carriage return.

But what I don't understand is why copying from Windows to Unix causes a problem. Usually, the reverse causes a problem because Unix uses only \n whereas Notepad expects \r\n.
No Strings Attached: A JavaScript graphics demo.
  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Joined: Sep 22, 2003
  • Posts: 6134
  • Loc: Seattle, WA
  • Status: Offline

Post July 7th, 2008, 7:37 am

HKt0p5 wrote:
I was editing it with Notepad supposedly clearing all the text in it in my PC and then uploading it but my site still didn't fix - but when I opened it with the file manager editor, it turned out there were two squares(?) in it.

It wasn't the copying that caused the problem, it was Notepad.
The Beer Monocle. Classy.
  • casablanca
  • Proficient
  • Proficient
  • User avatar
  • Joined: May 29, 2007
  • Posts: 481
  • Status: Offline

Post July 7th, 2008, 8:00 am

HKt0p5 wrote:
but when I opened it with the file manager editor, it turned out there were two squares(?) in it.

It's Notepad that can't open files saved on Unix. But files saved using Notepad should be openable elsewhere right?
No Strings Attached: A JavaScript graphics demo.

Post Information

  • Total Posts in this topic: 14 posts
  • Users browsing this forum: No registered users and 96 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.