/    Sign up×
Community /Pin to ProfileBookmark

javascript confirm/alert question

Hello, I am using javascript library:
[url]http://dhtmlx.github.io/message/[/url] for website wide prompting etc…

I am embedding their confirm function into a basic hyperlink as such:

<a href=”test.html” onclick=’dhtmlx.confirm({title:”Redirecting”, text:”You are now leaving the site.”});’>test link</a>

When the hyperlink is pressed the user does not get a chance to click OK/Cancel, the site automatically loads.

How can I implement if a user clicks Ok, they get redirected to the site?

I have tried using <a href=”test.html” onclick=’dhtmlx.confirm({title:”Redirecting”, text:”You are now leaving the site.”});if (! confirm(‘Continue?’)) return false;’>test link</a>

but that did not work.

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@PadonakApr 23.2013 — &lt;a href="#" onclick='dhtmlx.confirm({title:"Redirecting", text:"You are now leaving the site.",callback:function(result){if(result!==false){location.href='test.html'};}});'&gt;test link&lt;/a&gt;

i'm not sure what 'result' does it return, but i'd try this
Copy linkTweet thisAlerts:
@rnd_meApr 23.2013 — onclick=' return dhtmlx.confirm({title:"Redirecting", text:"You are now leaving the site."});'
Copy linkTweet thisAlerts:
@jarus323authorApr 24.2013 — &lt;a href="#" onclick='dhtmlx.confirm({title:"Redirecting", text:"You are now leaving the site.",callback:function(result){if(result!==false){location.href='test.html'};}});'&gt;test link&lt;/a&gt;

i'm not sure what 'result' does it return, but i'd try this[/QUOTE]


Thanks Padonak, that worked.

In the future, if I decide to add different js library's, the "callback:function(result){if(result!==false){location.href='test.html'};}});" will work as well? Is that just a universal / general way of a callback function?
Copy linkTweet thisAlerts:
@PadonakApr 24.2013 — i don't know)) it was just intuition
×

Success!

Help @jarus323 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.19,
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,
)...