3

I have a JQM-site that generates a pdf-file when submitting a form. All that is working fine, but I have a problem with the pdf not opening in a new window(open safari..) when started from home screen on iPhone.
It seems that I'm not the only one having problem with this, but I havn't found a working solution yet. I have no problem opening a new window in safari if I link to a static pdf with an anchor tag. My conclusion is that if I submit my form with an anchortag everything will work..! However when i try with the following code the result is just the same as if I post my form with a regular submit button.

Can anyone please help me with another solution? Or maybe tweak this so that it works?

This is my form:

 <form name="pdf" action="pdf_report1.php" data-ajax="false" target="_blank" id="pdf_report" method="POST">

<input type="hidden" name="customer_id" value="<?php echo $customer_id; ?>" >
<input type="hidden" name="date_from" value="<?php echo $date_from; ?>" >
<input type="hidden" name="date_to" value="<?php echo $date_to; ?>" >
<input type="hidden" name="user_id" value="<?php echo $user_id; ?>" >
<input type="hidden" name="maskin_id" value="<?php echo $maskin_id; ?>" >
<input type="hidden" name="akeri_id" value="<?php echo $akeri_id; ?>" >
<input type="hidden" name="littra_id" value="<?php echo $littra_id; ?>" >
<a href="javascript: document.getElementById('pdf_report').submit();" data-role="button">Create PDF</a>

</form>
4

3 回答 3

0

在调查了这个问题并且无法按照我希望使用表单的方式解决它之后,我采取了不同的方式。我没有使用表单,而是简单地在 URL 中添加了我需要的所有值,然后在目标页面上使用 get 提取它。也许不是最优雅的方式,但它对我有用。现在,当 Web 应用程序从 iPhone 上的主屏幕启动时,PDF 在 safari 的新窗口中打开,就像我想要的那样。

于 2013-07-21T09:38:23.280 回答
0

请务必将这些行放入 pdf_report1.php

header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="downloaded.pdf"');
于 2013-07-12T17:48:16.837 回答
0

我不太了解使用 iPhone 做这件事,但添加target = '_blank'应该会强制它在空白选项卡或页面中打开,具体取决于该浏览器的默认设置。前任:

<a href="javascript: document.getElementById('pdf_report').submit();" data-role="button" target="_blank">Create PDF</a>
于 2013-07-12T17:48:59.233 回答