我可以在CFDOCUMENT页面上显示弹出窗口吗?

时间:2018-01-29 18:55:28

标签: javascript coldfusion cfdocument

以下是我想在Coldfusion中做的事情:

在网页上有一个"下载" href链接,我希望在用户单击此链接时打开另一个浏览器选项卡。在新标签中,我通过Coldfusion中的CFDOCUMENT创建PDF。这本身就有效。

但是,由于PDF在加载到选项卡之前有延迟,我想向用户显示一个弹出窗口,表示PDF可能需要一些时间才能加载。

所以我试图做的就是这个序列:

User clicks "Download" -> 
On the same page, I trapped the link with jquery and displayed a popup 
window alerting the user there may be a delay ->
User clicks OK on the popup ->
Using javascript window.open, redirected to a new browser window for the PDF.

这是不成功的,因为浏览器不信任在javascript中使用window.open,并且由于弹出窗口阻止程序,新选项卡不会显示。

然后我想我会在加载PDF之前在新的浏览器标签中创建一个弹出窗口,但发现我无法在带有CFDOCUMENT的页面上使用javascript。

如果可以做任何事情,有关如何最好地实现这一点的任何想法吗?

1 个答案:

答案 0 :(得分:0)

我认为iframe可能是你的朋友。它允许您在pdf页面中显示另一个文档。

在评论中使用您的示例,我创建了两个文件:一个用于显示提示消息,另一个用于显示PDF。

cfprompt.cfm

<body>
<div> this is a test </div>
</body>
<cfflush> 
<iframe src="pdf.cfm" >
</iframe>

<强> pdf.cfm

<cfdocument format="pdf">
    <h1>Hello ColdFusion</h1>
    <p>This is <strong>PDF</strong> example document.</p>
    <p>Genereated at: <cfoutput>#TimeFormat(Now())# on #DateFormat(Now())#</cfoutput></p>
</cfdocument>

你仍然需要使用iframe的格式化/大小调整才能正确显示,但希望这可以让你显示PDF。

相关问题