Help - Search - Members - Calendar
Full Version: comment redirect with history.go(-1)
Movable Type Community Forum > Additional Resources > Tips and Tricks
prohtex
I am trying to modify Comments.pm to do a simple browser back after a comment is submitted, using this java script:

history.go(-1)

I need to do this because I have a comments block embedded in non-MT pages and I have no way of knowing exactly where comments are submitted from.

I tried this in Comments.pm but its not doing the trick:

CODE
sub do_red {
   my $app = shift;
   my $q = $app->{query};
   my $id = $q->param('id') or return $app->error("No id");
   my $comment = MT::Comment->load($id)
       or return $app->error("No such comment");
   my $uri = encode_html($comment->url);
   return <<HTML;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head><title>Redirecting...</title>  
<meta name="robots" content="noindex, nofollow">
<script type="text/javascript">
window.onload = history.go(-1);
</script></head>
<body>
<p><a href="#" onclick="history.go(-1)">Click here</a> if you are not redirected</p>
</body>
</html>
HTML
}


... But I am still getting sent to the URL I specify in the "static" tag in the template.. why? I can't figure out when Comments.pm spits out the HTML above.
prohtex
still haven't got it.... trying though
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.