/    Sign up×
Community /Pin to ProfileBookmark

Opening a PDF in a Popup

This is a continuation from here:

[url]http://www.webdeveloper.com/forum/showthread.php?t=75033[/url]

Opening a pdf in a popup seems to cause problems. Save the following and open in your browser.

[CODE]<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”
“http://www.w3.org/TR/html4/loose.dtd”>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
<script type=”text/javascript”>
function popIt(url) {
var leftPos = screen.width – 720;
ref = window.open(url,”thePop”,”menubar=1,resizable=1,scrollbars=1,status=1,height=400,width=710,left=”+leftPos+”,top=0″)
ref.focus();
}

function killPopUp() {
if(!ref.closed) {
ref.close();
}
}
</script>
</head>

<body>
<p>1. Click here: <a href=”http://www.webdeveloper.com” target=”ref” onclick=”popIt(this.href);return false;”>Open html page in a popup</a></p>
<p>2. Click here: <a href=”javascript:killPopUp();”>Close the popup</a> </p>
<p>3. Click here: <a href=”http://illiad.evms.edu/sample.pdf” target=”ref” onclick=”popIt(this.href);return false;”>Open pdf in a popup</a> </p>
<p>4. Click here: <a href=”javascript:killPopUp();”>Close the popup</a></p>
<p>Both popups are created using the exact same function. The attempt to close the popups is performed by the same function. The html page closes, but the pdf does not. Why??? </p>
</body>
</html>
[/CODE]

You will see that the function killPopUp closes the popup when the popup opens an html page. However, if the popup loads a pdf, the function fails (No error message). It makes me think that the opening of a pdf somehow changes the window name.

Thoughts?

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @betheball spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...