PHP headers inside of a javascript condition?
问题 I'd like to send headers with PHP, inside of a javascript condition. Is that possible? if ($('body').hasClass('browserChrome')) { <?php header("Content-Type: application/x-chrome-extension"); header('Content-Disposition: attachment; filename="http://example.com/file.crx"'); header("Pragma: no-cache"); header("Expires: 0"); ?> } 回答1: That won't work. First, your web server will execute the PHP script, resulting in an HTML page with JavaScript. That is then sent to the user's web client, which