1,105,221 Community Members

Close() not working in IE 8

Member Avatar
mgranger96
Newbie Poster
11 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

I have a need to close a popup window after a certain amount of time. I have tried many different ways to do it with no luck in IE. Works fine in Firefox, Safari, and Google Chrome.

It seems to be a problem with IE referencing the window I have opened by the variable name.

Here is the code I've been using:

var newWindow ;

function FNUMBER(SOP) 
{
	newWindow = window.open(SOP,'','left=0px,top=0px,width=800,height=670');
	setTimeout('newWindow.close();',3000);
}

This function is called from another button in the html file that opens a .pdf document inside a browser window.

No matter what I try to do, IE will not reference newWindow to do anything.

Thanks for any help.

Member Avatar
fxm
Posting Pro
591 posts since Apr 2010
Reputation Points: 23 [?]
Q&As Helped to Solve: 75 [?]
Skill Endorsements: 0 [?]
 
0
 

Works fine here.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
  <head>
    <meta name="generator" content=
    "HTML Tidy for Windows (vers 25 March 2009), see www.w3.org">
    <script type="text/javascript">
var newWindow ;

    function FNUMBER(SOP) 
    {
        newWindow = window.open(SOP,'','left=0px,top=0px,width=800,height=670');
        setTimeout('newWindow.close();',5000);
    }
    </script>
    <title></title>
  </head>
  <body>
    <form>
      <input onclick="FNUMBER('http://www.google.com')" type="button" value='test'>
    </form>
  </body>
</html>

Google opens, and 5 seconds later it closes.

Member Avatar
mgranger96
Newbie Poster
11 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

Thanks fxm,

Do you think the issue is that the link is to a pdf document? It works just fine when I change the link to Google, but when I make the change back to the pdf document it just hangs there and I get the error icon in IE.

Member Avatar
fxm
Posting Pro
591 posts since Apr 2010
Reputation Points: 23 [?]
Q&As Helped to Solve: 75 [?]
Skill Endorsements: 0 [?]
 
0
 

Interesting!

There definitely is a problem in IE with pdf files opened in this way.
When window.close is attempted, javascript throws a "Permission denied" error.
I'm guessing this is a security model issue.

Searching this forum returns threads going back months, and a Google search turns up discussions going back [literally] years.

If there is a workaround, I haven't yet found it.

Member Avatar
mgranger96
Newbie Poster
11 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

Thanks so much for your help!

This is an internal system, so we may end up just switching default browsers. Seems to be the easier thing to do considering IE and its quirks.

Member Avatar
fxm
Posting Pro
591 posts since Apr 2010
Reputation Points: 23 [?]
Q&As Helped to Solve: 75 [?]
Skill Endorsements: 0 [?]
 
0
 

FASCINATING!

I created a 'fake' page 'test.html'

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
  <head>
    <meta name="generator" content=
    "HTML Tidy for Windows (vers 25 March 2009), see www.w3.org">
    <title></title>
  </head>
  <frameset>
    <frame src="test.pdf">
  </frameset>
</html>

and opened that

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<meta http-equiv="X-UA-Compatible" content="IE=IE6" />
<html>
  <head>
    <meta name="generator" content=
    "HTML Tidy for Windows (vers 25 March 2009), see www.w3.org">
    <script type="text/javascript">
var newWindow ;

    function FNUMBER(SOP) 
    {
        newWindow = window.open(SOP,'','left=0px,top=0px,width=800,height=670');
        setTimeout('newWindow.close();',5000);
    }
    </script>
    <title></title>
  </head>
  <body>
    <form>
      <input onclick="FNUMBER('test.html')" type="button" value='test'>
    </form>
  </body>
</html>

instead of opening the pdf directly. Works perfectly in IE8 (and, I expect, all the others).

Member Avatar
mgranger96
Newbie Poster
11 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

Thanks again for your help.

The issue I'd have with that solution is that we have over 1200 pdf files. Each of these is given a javascript variable name (I know bad way of doing it, but until I have time to change it I'm stuck with what they've done already).

How can I call that variable from the original html file and place that in the test.html file without making a test page for all 1200 pdfs?

Member Avatar
fxm
Posting Pro
591 posts since Apr 2010
Reputation Points: 23 [?]
Q&As Helped to Solve: 75 [?]
Skill Endorsements: 0 [?]
 
0
 

Here is the cure for the latest sub-problem.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<meta http-equiv="X-UA-Compatible" content="IE=IE6" />
<html>
  <head>
    <meta name="generator" content=
    "HTML Tidy for Windows (vers 25 March 2009), see www.w3.org">
    <script type="text/javascript">
var newWindow ;

    function FNUMBER(SOP) 
    {
        newWindow = window.open(SOP,'','left=0px,top=0px,width=800,height=670');
        setTimeout('newWindow.close();',15000);
    }
    </script>
    <title>Show PDF</title>
  </head>
  <body>
    <form>
      <input onclick="FNUMBER('test.html?test.pdf')" type="button" value='test'>
    </form>
  </body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
  <head>
    <meta name="generator" content=
    "HTML Tidy for Windows (vers 25 March 2009), see www.w3.org">
    <title>Fake HTML</title>
  </head>
<body>
    <iframe id='frm' height=100% width=100% src=""></iframe>
<script>
document.getElementById('frm').setAttribute('src',location.search.substring(1))
</script>
</body>
</html>

I'm actually a little surprised that this approach works.

Member Avatar
mgranger96
Newbie Poster
11 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

Thanks, but I think I may be missing something or I've been staring at this for entirely way too long.

Inside the button in the following code is where a variable is called that holds the location of the pdf.

<input onclick="FNUMBER('test.html?test.pdf')" type="button" value='test'>

An example of what is being done is:

<td height="60" align="center"><input title="ENG ES00-001 Nail Mark Depth" type="button" name="ES00-001" id="bdoublecolumn" value="Tang & Shield Stamp Depth" onclick="FNUMBER(Button106)"  /></td>

Where Button106 is calling test.pdf inside the javascript file. The code in the javascript looks like this:

var Button106="test.pdf"

I'm not sure what I am asking can even be done. I'd really like not to change 75 html pages where these buttons are housed.

Thanks again for your help.

Member Avatar
fxm
Posting Pro
591 posts since Apr 2010
Reputation Points: 23 [?]
Q&As Helped to Solve: 75 [?]
Skill Endorsements: 0 [?]
 
0
 

It's just a matter of recognizing the pieces.

Assuming that the Button### variables all contain filenames [received by the function as the calling parameter], then leave the onclick= statements exactly as they are

<td height="60" align="center"><input title="ENG ES00-001 Nail Mark Depth" type="button" name="ES00-001" id="bdoublecolumn" value="Tang & Shield Stamp Depth" onclick="FNUMBER(Button106)"  /></td>

and adjust the function

newWindow = window.open('test.html?'+SOP,'','left=0px,top=0px,width=800,height=670');
        setTimeout('newWindow.close();',15000);

accordingly.

In test.html the ?-part of the URI is used to open the specified document.

Member Avatar
mgranger96
Newbie Poster
11 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

Unbelievable...Thank you very much!

Member Avatar
fxm
Posting Pro
591 posts since Apr 2010
Reputation Points: 23 [?]
Q&As Helped to Solve: 75 [?]
Skill Endorsements: 0 [?]
 
0
 

You're welcome.
Now look around for the up arrow and the 'mark as solved' link :)

Question Answered as of 3 Years Ago by fxm
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: