Created
December 19, 2009 18:49
-
-
Save karteek/260200 to your computer and use it in GitHub Desktop.
A way to enable custom 404 for Tumblr. Well, it 'kinda' works
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
/* Works for me */ | |
var text_posts = document.getElementsByClassName("regular"); | |
var text_404 = "The URL you requested could not be found."; | |
var title_404 = "Not Found"; | |
if(text_posts.length == 1){ | |
var bodyNode = text_posts[0].lastChild; | |
if(bodyNode.previousSibling.textContent == text_404) { | |
// titleNode.innerHTML = "<a href='/'>Not Found</a>"; | |
var blog_loc = "http://" + document.domain + "/"; | |
var query = window.location.href.slice(blog_loc.length); | |
var tokens = query.toLowerCase().split('/'); | |
var keyword = tokens.join(" "); | |
var bodyContent = "Looks like you came from an old bookmark, or just looking for a page that doesn't exist. Were you looking for <span class='tg'><a href='/search/"+ escape(keyword) +"'>"+keyword+"</a></span>"; | |
bodyNode.previousSibling.innerHTML = bodyContent; | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment