/    Sign up×
Community /Pin to ProfileBookmark

Close a Window

Okay I have searched the forum (this and forty others) and still cannot make this work.

I have tried many different scripts but none seem to work.

Here is my problem. As with another thread I have seen I want to launch an HTML file from a CD-ROM. I need this window to open centred with toolbars off etc and have managed this part only by calling this window from another window. This lets me control size toolbars etc.

I am having real problems closing the calling window.

I am also not sure how to call two scripts in the <Body tag.

Thanks to everyone who can help

to post a comment
JavaScript

15 Comments(s)

Copy linkTweet thisAlerts:
@ShrineDesignsFeb 27.2003 — you must get permission from the user to close that window


to call two or more scripts:

Example:

<body onLoad="funcOne(); funcTwo(); etc()">
Copy linkTweet thisAlerts:
@pyroFeb 27.2003 — [i]Originally posted by garyhay [/i]

[B]I am having real problems closing the calling window.[/B][/QUOTE]
window.opener.close();
Copy linkTweet thisAlerts:
@garyhayauthorFeb 27.2003 — window.opener.close();[/QUOTE]

Sorry I an not sure where this goes.

In the Head or Body section and of which window. The pop up or the opener.

Thanks again
Copy linkTweet thisAlerts:
@pyroFeb 27.2003 — Put it in the <head> section of you popup.

ShrineDesigns-

You might be interested in this: http://www.infinitypages.com/research/selfclose.htm
Copy linkTweet thisAlerts:
@garyhayauthorFeb 27.2003 — Thanks

nearly there now.

What I now need (I assume it's possible) is to integrate the self.close example so it happens automatically.

I would realy appreciate it if you can get me over this final hurdle.

I have been at this for too many hours now my head has just stopped thinking straight. -_-_-_--_--___
Copy linkTweet thisAlerts:
@pyroFeb 27.2003 — Is this what you need?

&lt;script language="javascript" type="text/javascript"&gt;
function closewin()
{
self.close();
}
&lt;/script&gt;
&lt;body onLoad="opener=self;closewin();"&gt;
Copy linkTweet thisAlerts:
@CharlesFeb 27.2003 — [font=georgia]This is one of those questions that keeps geting asked. And you cannot do what it is that you want to do, not with JavaScript. But you might find this link of some use: http://tech.irt.org/articles/js191/.[/font]
Copy linkTweet thisAlerts:
@pyroFeb 27.2003 — What are you talking about, Charles? I think you _can_ do what he is looking to do with javascript... ?
Copy linkTweet thisAlerts:
@pyroFeb 27.2003 — A couple more things...

Just because you can do this, doesn't mean you should. I personally wouldn't be to happy if the sites I went to were closeing my windows on me, especially a parent window. Also, you will want to remember to open your new window _before_ the self.close(); otherwise, all it will do when they go to your site is close the browser window. :p
Copy linkTweet thisAlerts:
@garyhayauthorFeb 27.2003 — That never worked

I do think that Javascript just can't do this as I have tried everything.

I have posted my pages here [URL]http://www.e-commerce-aberdeen.com/js/2.htm[/URL]

Thanks again
Copy linkTweet thisAlerts:
@garyhayauthorFeb 27.2003 — I would never do this on a web site. It's for a CD-ROM as my thread starting message explained.

I will open the first window so I can set the size of the second window and remove toolbars from it etc.
Copy linkTweet thisAlerts:
@pyroFeb 27.2003 — [i]Originally posted by garyhay [/i]

[B]I do think that Javascript just can't do this as I have tried everything.[/B][/QUOTE]
The link you posted worked for me in IE6...
Copy linkTweet thisAlerts:
@garyhayauthorFeb 27.2003 — Hey that is wierd

It does work where it was posted just not the local disk??

It still gives the "The Window you are viewing.... " message.

Maybe it only works if the self window is called from another web page. I will test it out
Copy linkTweet thisAlerts:
@pyroFeb 27.2003 — This is working from my desktop...

[upl-file uuid=6d622dcd-c26b-44f2-b902-4bdc7002fc2d size=376B]openclose.txt[/upl-file]
Copy linkTweet thisAlerts:
@garyhayauthorFeb 27.2003 — Thanks very much for your help. I am afraid my lack of understanding of the javascript syntax was to blame.

Too many " splitting the java functions in the OnLoad=

Cheers.?
×

Success!

Help @garyhay 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 5.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...