/    Sign up×
Community /Pin to ProfileBookmark

Close Window That Has No Opener?

My e-mailing list sends out a confirm message. The person clicks the link in their email (from, let’s say, an email client rather than webmail).

The link opens their browser and a “subscription confirmed” message appears.

I want a link that says “Close Window”.

I’ve tried onclick=”self.close();” … didn’t work.

Nor did “window.close():”

How do I do this?

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@FrankTheTankJul 15.2008 — Looks like you made a typo...?

try window.close();

Frank
Copy linkTweet thisAlerts:
@rnd_meJul 15.2008 — self === window

perhaps you can't. its a user pref in Firefox, disabled by default.

not sure about others...
Copy linkTweet thisAlerts:
@robindeanauthorJul 15.2008 — Yeah, I meant to type window.close(); which is what I tried in my document.

Neither works and I suppose it can't be done. Ah well, no big deal I suppose.

Thanks for the help.
Copy linkTweet thisAlerts:
@eCatJul 15.2008 — You want a button or a link?

[CODE]
<form>
<input type=button value="Close Window" onClick="javascript:window.close();">
</form>
[/CODE]


[CODE]<a href="javascript:window.close();">Close Window</a>[/CODE]
Copy linkTweet thisAlerts:
@toicontienJul 15.2008 — As a general rule, JavaScript is not allowed to close a window it didn't spawn in the first place. I wonder perhaps if you are running into this snag?
Copy linkTweet thisAlerts:
@robindeanauthorJul 15.2008 — Yep. That's the snag.
Copy linkTweet thisAlerts:
@KorJul 16.2008 — There is no way to close a window using javascript methods if the window [I]was not[/I] opened via a javascript method (if it is not a popup).
×

Success!

Help @robindean 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.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: @nearjob,
tipped: article
amount: 1000 SATS,

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

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