www.webdeveloper.com
Results 1 to 5 of 5

Thread: javascript confirm/alert question

  1. #1
    Join Date
    Apr 2013
    Posts
    2

    javascript confirm/alert question

    Hello, I am using javascript library:
    http://dhtmlx.github.io/message/ 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.

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,633
    Code:
    <a href="#" onclick='dhtmlx.confirm({title:"Redirecting", text:"You are now leaving the site.",callback:function(result){if(result!==false){location.href='test.html'};}});'>test link</a>
    i'm not sure what 'result' does it return, but i'd try this
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  3. #3
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    Code:
    onclick=' return dhtmlx.confirm({title:"Redirecting", text:"You are now leaving the site."});'

  4. #4
    Join Date
    Apr 2013
    Posts
    2
    Quote Originally Posted by Padonak View Post
    Code:
    <a href="#" onclick='dhtmlx.confirm({title:"Redirecting", text:"You are now leaving the site.",callback:function(result){if(result!==false){location.href='test.html'};}});'>test link</a>
    i'm not sure what 'result' does it return, but i'd try this
    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?

  5. #5
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,633
    i don't know)) it was just intuition
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles