Forum Redirect
<head>
<title>Redirecting to the comment</title>
<style type=text/css>
.redirect-message {
    text-align: center;
    position: relative;
    top: 40%;
    margin-top: -40px;
    font-family: Tahoma, arial, sans-serif;
    font-size: 0.95em;
    color: #333;
}
.redirect-message span, .redirect-message a {
    font-size: 0.85em;
}
</style>
</head>
<body>
 
<div class="redirect-message">
Please wait while we redirect you to the comment.
<br>
<br>
<span>If you are not redirected automatically, please click the link below.</span>
<br>
<br>
 
<script type="text/javascript">
<!--
function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}
 
var parent = gup( 'parent' );
var anchor = gup( 'anchor' );
var bmc = "http://bmcenterprises.wikidot.com/"
var hash = "#"
 
function redirect() {
window.top.location.href = "http://bmcenterprises.wdfiles.com/local--code/css3:forum-redirect2/1?parent=" + parent + "&anchor=" + anchor;
}
redirect();
 
document.write('<a href="' + bmc + parent + hash + anchor + '">http://bmcenterprises.wikidot.com/' + parent + hash + anchor + '</a>');
//-->
</script>
 
</div>
 
</body>

Discussion

No comments yet. Start the discussion…17 comments

01 Jan 2011 21:41

Test comment…

Edit

01 Jan 2011 23:42

And it works!

Edit

01 Jan 2011 23:47

Testing from firefox…

Edit

02 Jan 2011 00:02

Test comment from frosty St Paul, Minnesota

Edit

02 Jan 2011 01:01

Testing… :D

Edit

02 Jan 2011 01:03

Hey Bryce, why are you making it onLoad? Shouldn't it redirect if it wasn't onLoad anyway?

Edit

02 Jan 2011 01:08

This is where my lack of javascript knowledge shows up… what's the alternative to onLoad?

Edit

02 Jan 2011 01:34

Put redirect(); after the function code for redirect to call it immediately:

function redirect() {
window.top.location.href = "http://bmcenterprises.wdfiles.com/local--code/css3:forum-redirect2/1?parent=" + parent + "&anchor=" + anchor;
}

Edit

02 Jan 2011 02:34

Done. Thanks for that Kenneth. I also changed the location of the code to http://bmcenterprises.wikidot.com/r to make the URL a little more neat. I think I'm almost ready to take this to http://css3.wikidot.com.

Edit

02 Jan 2011 03:50

That's good! I'm looking forward to seeing it in action on css3.wikidot.com :D

Edit

02 Jan 2011 03:52

And I love the "saving now" and "page saved" replacement. Please do a tutorial on it! :D

Edit

02 Jan 2011 03:55

Hmm, Firefox doesn't seem to like the change from onLoad to the direct function call - it just stops half way through the redirect. Is there something particularly bad about using onLoad?

Edit

02 Jan 2011 04:05

Not really. You can add onLoad there for FF. (I.e. Have both)

Edit

02 Jan 2011 06:31

The redirect fails completely in Opera, so I'll have to spend a bit more time refining the code before moving it over to http://css3.wikidot.com.

Edit

02 Jan 2011 08:56

You might want to try putting all three of the following as redirects:

window.top.location.href=theLocation;
window.parent.location.href=theLocation;
window.top.location.replace(theLocation);

Edit

02 Jan 2011 09:04

I think the problem in Opera is to do with grabbing the variables from the URL - so I'll look into some other, similar solutions.

Edit

26 Apr 2011 08:07

test

Edit

Add a new comment

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License