"Member not found" error when opening PDFs in new window

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>
 
J

johkar

johkar said:
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.

Sorry, here is correct HTML:

<!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>
<body>
<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">Link 1</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">Link 2</a></p>
</body>
</html>
 
J

johkar

johkar said:
Sorry, here is correct HTML:

<!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>
<body>
<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">Link 1</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">Link 2</a></p>
</body>
</html>

I found the solution here: http://tinyurl.com/yd54h8
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,836
Messages
2,569,748
Members
45,545
Latest member
rapter____0

Latest Threads

Top