Javascript hack closewindow problem on Windows

They have: 160 posts

Joined: Mar 2002

I have this problem only on windows so...

(Works ok on mac osx and mac os9)

What I wanted is a small window that works as a navigator for a big window.

To do this I have an initial page that onloads a new page with smaller dimensions. Then the initial page must close.

Unfortunately because I already have one onload I can't do a "onload = windowclose()" can I?

Here's the code:

BODY bgcolor="#000000" onload="MM_openBrWindow('index2.html','index2','width=280,height=160,top=0,left=0')"

So what I came up with is I have the initial page meta to another page with an onload = closewindow()

The problem is when I try it on my windows machine, windows tells me the page is trying to close and asks if it's OK.

Here's the url if you want to check it out:

http://www.alogical.com/new

I'm doing this site as a demo to show I can write or manipulate Javascript to a reasonable degree. I'm not great at coding and not trying to be, still learning (as if I’ll ever stop learning).

I know this is a hack and I know there is probably a better way, so thanks if any one can suggest anything.

[email protected]

http://www.alogical.com

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

They have: 447 posts

Joined: Oct 1999

Quote: Unfortunately because I already have one onload I can't do a "onload = windowclose()" can I?

sure ... you can do some thing like this:
onload="MM_openBrWindow('index2.html','index2','width=280,height=160,top=0,left=0');window.close();"

or write a function for it:
<script language="javascript">
function dothings() {
  MM_openBrWindow('index2.html','index2','width=280,height=160,top=0,left=0');
  window.close();
}
</script>

<body onload="dothings()">
'

dk01's picture

He has: 516 posts

Joined: Mar 2002

Rob's response is correct. You could do what he is saying but would still get the warning about "This window is trying to close itself. This is a security feature on IE/win. I wish there was a workaround but there is not since it is meant for security. Sorry. guess you will just have to find another way to do it.
-dk

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

FYI, if you're closing a child window spawned by a script on your page, then you'd get no warning, but if you try closing a user-opened client, there will be a warning.

dk01's picture

He has: 516 posts

Joined: Mar 2002

Yeah that's true. Maybe you could try to tweak your plan so that the child window closes instead.
-dk

They have: 160 posts

Joined: Mar 2002

Thanks for all the advice. I think I might be able to tweak it now.

They have: 160 posts

Joined: Mar 2002

The answer to this problem is to open the navigator window as a child of the content window. The content window also needs a function with these two methods to size and locate it:

window.opener.moveTo(300,0)
window.opener.resizeTo(800,600);

My problem was that I was trying to open the content window as a child of the navigation window.

[email protected]

http://www.alogical.com

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.