J
johkar
Why does if(win==null || win.closed) return true after one PDF is open.
Something very wierd going on with IE 6. I also get a member not
found error if a child window is already open. This script works fine
if the child window contains HTML, just not a PDF. Ideas? Note: These
are not my PDFs, I just found some on the Net so you could test.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>Untitled Document</title>
<script type="text/javascript">
var win;
function winfocus(){
if(!(win==null || win.closed))
win.focus();
}
function newWindow(myurl,mywidth,myheight,resize){
var myDate=new Date();
var myTime=myDate.getTime();
var URL=((myurl.indexOf('?') > -1))?myurl + '&time=' + myTime:myurl +
'?time=' + myTime;
var w=mywidth;
var h=myheight;
var winname='popWindow';
var winl = (screen.width - w) / 2, wint = (screen.height - h) / 2;
var
winresize=((resize=='resize'))?'scrollbars=yes,resizable=yes':'scrollbars=no,resizable=no';
var winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl +
',toolbar=no,status=no,menubar=no,' + winresize;
if(win==null || win.closed)
win=window.open(URL, winname, winprops);
win.focus();
document.onclick=winfocus;
}
</script>
</head>
<p><a href="http://www.nsf.gov/pubs/2007/nsf07505/nsf07505.pdf"
onclick="newWindow('http://www.nsf.gov/pubs/2007/nsf07505/nsf07505.pdf',500,400,'resize');return
false"></a></p>
<p><a href="http://grants.nih.gov/grants/funding/phs398/biosketch.pdf"
onclick="newWindow('http://grants.nih.gov/grants/funding/phs398/biosketch.pdf',500,400,'resize');return
false"></a></p>
<body>
</body>
</html>
Something very wierd going on with IE 6. I also get a member not
found error if a child window is already open. This script works fine
if the child window contains HTML, just not a PDF. Ideas? Note: These
are not my PDFs, I just found some on the Net so you could test.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>Untitled Document</title>
<script type="text/javascript">
var win;
function winfocus(){
if(!(win==null || win.closed))
win.focus();
}
function newWindow(myurl,mywidth,myheight,resize){
var myDate=new Date();
var myTime=myDate.getTime();
var URL=((myurl.indexOf('?') > -1))?myurl + '&time=' + myTime:myurl +
'?time=' + myTime;
var w=mywidth;
var h=myheight;
var winname='popWindow';
var winl = (screen.width - w) / 2, wint = (screen.height - h) / 2;
var
winresize=((resize=='resize'))?'scrollbars=yes,resizable=yes':'scrollbars=no,resizable=no';
var winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl +
',toolbar=no,status=no,menubar=no,' + winresize;
if(win==null || win.closed)
win=window.open(URL, winname, winprops);
win.focus();
document.onclick=winfocus;
}
</script>
</head>
<p><a href="http://www.nsf.gov/pubs/2007/nsf07505/nsf07505.pdf"
onclick="newWindow('http://www.nsf.gov/pubs/2007/nsf07505/nsf07505.pdf',500,400,'resize');return
false"></a></p>
<p><a href="http://grants.nih.gov/grants/funding/phs398/biosketch.pdf"
onclick="newWindow('http://grants.nih.gov/grants/funding/phs398/biosketch.pdf',500,400,'resize');return
false"></a></p>
<body>
</body>
</html>