/    Sign up×
Community /Pin to ProfileBookmark

function drawAlert () popup message

I am using the following script that creates a popup alert box when a visitor clicks on a link that will leave the website (target=”_blank”). The dialog box opens correctly, and the “OK” button functions properly, however when you click on the red “X” box in the top right, it still sends the visitor to the link. How can I make the “X” just close the dialog box?

in <HEAD> section
<SCRIPT LANGUAGE=”JavaScript”>
<!– This script and many more are available free online at –>
<!– The JavaScript Source!! [url]http://javascript.internet.com[/url] –>
<!– Begin
function drawAlert () {
alert (“You are now leaving First Bank of Utica’s website. When you click on OK you will be transferred to a website that is not operated by our bank. First Bank of Utica is not responsible for the content on the alternate site. First Bank of Utica does not represent the third party or the member if the two enter into a transaction. Privacy and security policies of the alternate site may differ from those practiced at this bank.”);
}
// End –>
</SCRIPT>

In the <BODY> section as part of the href tag:
<a onClick=”drawAlert()” target=”_blank” href=”http://www.breezafansusa.com/website“>

Thanks in advance.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@web_bertJul 22.2009 — use confirm instead of alert, and return value of the confirm box. Use the return value to decide whether to follow the link:

[CODE]
function drawAlert () {
return confirm ("You are now leaving First Bank of Utica's website. When you click on OK you will be transferred to a website that is not operated by our bank. First Bank of Utica is not responsible for the content on the alternate site. First Bank of Utica does not represent the third party or the member if the two enter into a transaction. Privacy and security policies of the alternate site may differ from those practiced at this bank.");
}
[/CODE]


with this:

[CODE]
<a onclick="return drawAlert()" target="_blank" href="http://www.breezafansusa.com/website">
[/CODE]
×

Success!

Help @frameitsam 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.5,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

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