HTML code for automatic history.back reload

  • HKt0p5
  • Graduate
  • Graduate
  • User avatar
  • Posts: 135
  • Loc: Bulgaria

Post 3+ Months Ago

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

Post 3+ Months Ago

  • casablanca
  • Proficient
  • Proficient
  • User avatar
  • Posts: 481

Post 3+ Months Ago

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>
  • Fabinator
  • Proficient
  • Proficient
  • Fabinator
  • Posts: 467

Post 3+ Months Ago

This article explains how to make a custom 404 page, and just put casablanca's code in it ;)
  • HKt0p5
  • Graduate
  • Graduate
  • User avatar
  • Posts: 135
  • Loc: Bulgaria

Post 3+ Months Ago

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
  • Posts: 481

Post 3+ Months Ago

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>
  • HKt0p5
  • Graduate
  • Graduate
  • User avatar
  • Posts: 135
  • Loc: Bulgaria

Post 3+ Months Ago

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
  • Posts: 481

Post 3+ Months Ago

.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.
  • HKt0p5
  • Graduate
  • Graduate
  • User avatar
  • Posts: 135
  • Loc: Bulgaria

Post 3+ Months Ago

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
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

those two squares were probably spaces ( \n\n ) or tabs ( \r\r ) or some other special case characters.
  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Posts: 6243
  • Loc: Seattle, WA

Post 3+ Months Ago

\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.
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

\t is a tab correct?
  • casablanca
  • Proficient
  • Proficient
  • User avatar
  • Posts: 481

Post 3+ Months Ago

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.
  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Posts: 6243
  • Loc: Seattle, WA

Post 3+ Months Ago

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.
  • casablanca
  • Proficient
  • Proficient
  • User avatar
  • Posts: 481

Post 3+ Months Ago

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?

Post Information

  • Total Posts in this topic: 14 posts
  • Users browsing this forum: No registered users and 76 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.