How can JavaScript be used for redirection in PHP and what are the potential drawbacks?

JavaScript can be used for redirection in PHP by using the `window.location` method to redirect the user to a different page. This can be useful for scenarios where server-side redirection is not possible or practical. However, using JavaScript for redirection can have drawbacks such as potential issues with browser compatibility and accessibility.

<?php
// PHP code to check a condition and redirect using JavaScript
if ($condition) {
    echo '<script>window.location = "newpage.php";</script>';
}
?>