WordPress Redirect post to outside website based on useragent

using Javascript to get the User Agent. Then based on the User Agent do a redirect.

something like this:

var ua = navigator.userAgent; 

if (ua === 'whatever userAgent you are testing for')
{
   window.location = 'https://newurl.com'
}

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)