you could use "internal_redirect" 's with apache and mod_perl. now i know that is not what you were asking for but it would be easier and lot less stressful. you would take the HTTP_USER_AGENT environment var and compare it to a hash of known browsers, then pull a
Code:
$r->internal_redirect($redirect_var);
and it would seem to the user that the page never redirected. this is server side, using mod_perl and apache but personally i think it would work a lot better. also Dreamweaver has javascripts like the one you were talking about installed as ready to use "behaviours".