Here's my scenario:
这是我的情景:
I have a page containing several links; each link is meant to open another window containing a pdf. The catch is, I can't have that window directly go to the PDF because I do not want to make it apparent to the end user the PDF is located on another domain, and I need to name the PDF differently than how it would regularly show up.
我有一个包含几个链接的页面;每个链接用于打开另一个包含pdf的窗口。问题是,我不能将该窗口直接转到PDF,因为我不想让最终用户明白PDF是否位于另一个域上,我需要将PDF命名为与常规用户不同的名称出现。
So then I have two pages: One is blank, and only contains a frame to be used for displaying the pdfs:
那么我有两个页面:一个是空白的,只包含一个用于显示pdf的框架:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>[PDF]</title>
</head>
<frameset>
<frame id="pdfFrame">
</frameset>
</html>
And on the page with the links, I have the following function that calls this page (we'll call the above page "pdf.html"):
在带有链接的页面上,我有以下函数调用此页面(我们将上面的页面称为“pdf.html”):
function OpenWindow(pdfTitle, pdfLocation)
{
var myWindow = window.open("pdf.html", "", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=700,height=600");
myWindow.document.title = pdfTitle;
myWindow.document.getElementById('pdfFrame').src = pdfLocation;
}
For the most part, this seems to work fine; however, on occasion the pop up window will not be loaded prior to the lines above that setup the title/frame source, and it will crash (or not load properly, at least).
在大多数情况下,这似乎工作正常;但是,有时弹出窗口将不会在上面设置标题/帧源的行之前加载,并且它将崩溃(或者至少没有正确加载)。
My question is, is there a simple way for me to add in some sort of blocking call after opening the window, to wait until we're ready to run this code?
我的问题是,有一种简单的方法让我在打开窗口后添加某种阻塞调用,等到我们准备好运行这段代码?
Thanks!
1 个解决方案
#1
3
You can't really block until it's loaded but you can set an event in the popup, like this:
在加载之前你无法阻止,但你可以在弹出窗口中设置一个事件,如下所示:
myWindow.onload = function()
{
document.title = pdfTitle;
document.getElementById('pdfFrame').src = pdfLocation;
}
#1
3
You can't really block until it's loaded but you can set an event in the popup, like this:
在加载之前你无法阻止,但你可以在弹出窗口中设置一个事件,如下所示:
myWindow.onload = function()
{
document.title = pdfTitle;
document.getElementById('pdfFrame').src = pdfLocation;
}