我已经设法使用下面的代码片段,在浏览器中打开pdf。而不是在同一页面打开,我希望它在新的浏览器选项卡中打开。
我没有使用标签。 这段代码调用了许多动作,最后它应该显示pdf。 它工作正常,但我希望它在一个新的选项卡中打开。
这可能吗? 如果可以的话,请向我解释如何这样做。
我使用Magento(EE 12.02)应用程序及其在PHP 5.3上。
$file = $pdf_file_path; $filename = $file_name; header('Content-type: application/pdf'); header('Content-Disposition: inline; filename="' . $filename . '"'); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . filesize($file)); header('Accept-Ranges: bytes'); @readfile($file);I have managed to use the below snippet of code, to open a pdf in a browser.Instead of opening in the same page, I would like it to open in a new browser tab.
I am not using an tag. This piece of code invokes a number of actions and at the end it is supposed to display the pdf. It works fine, but i would like it to open in a new tab.
Is this possible? and if so could you please explain to me how to do so.
Im using a Magento (EE 12.02) application and its on php 5.3.
$file = $pdf_file_path; $filename = $file_name; header('Content-type: application/pdf'); header('Content-Disposition: inline; filename="' . $filename . '"'); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . filesize($file)); header('Accept-Ranges: bytes'); @readfile($file);最满意答案
你不能从那个请求那里做到这一点。
但是您可以通过在标签中添加target =“_ blank”来在新的浏览器窗口中打开链接,然后浏览器通常会使用新标签。
You can't do that from that request.
But you can open the link in a new browser window by adding target="_blank" to your a tag, then browsers usually will use a new tab.
更多推荐
发布评论