Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Query User

GameFreak7744GameFreak7744 Posts: 36Member
Is it possible to use Java Script to question if a user really wants to follow a link, and then follow it if they say yes, and cancel if they say no?

Thanks in advance for any help.
~Joey~

Comments

  • zibadianzibadian Posts: 6,349Member
    : Is it possible to use Java Script to question if a user really wants to follow a link, and then follow it if they say yes, and cancel if they say no?
    :
    : Thanks in advance for any help.
    : ~Joey~
    :
    Yes, it's possible. You can do this by setting the onclick() event of the links, or by placing a function call in the link's href. In the javascript function you then ask the user to proceed. If he doesn't do nothing, otherwise open the page using the window.location property. See http://www.w3schools.com/htmldom/obj_win_location.asp for more info and examples.
  • GameFreak7744GameFreak7744 Posts: 36Member
    : Yes, it's possible. You can do this by setting the onclick() event of the links, or by placing a function call in the link's href. In the javascript function you then ask the user to proceed. If he doesn't do nothing, otherwise open the page using the window.location property. See http://www.w3schools.com/htmldom/obj_win_location.asp for more info and examples.
    :

    Thanks for the help.
    I'm pretty clueless about this whole thing, so please bear with me. If I leave in the href of the links, then they just follow normally, and if I remove it they stop acting like links, with the mouse pointer not changing when placed over them, and no formatting changes.
    Am I doing something wrong?
  • mac_doggiemac_doggie Posts: 488Member
    : : Yes, it's possible. You can do this by setting the onclick() event of the links, or by placing a function call in the link's href. In the javascript function you then ask the user to proceed. If he doesn't do nothing, otherwise open the page using the window.location property. See http://www.w3schools.com/htmldom/obj_win_location.asp for more info and examples.
    : :
    :
    : Thanks for the help.
    : I'm pretty clueless about this whole thing, so please bear with me. If I leave in the href of the links, then they just follow normally, and if I remove it they stop acting like links, with the mouse pointer not changing when placed over them, and no formatting changes.
    : Am I doing something wrong?
    :

    If you don't have an href an anchor stops acting like a link indeed. so why use the onclick You can also put JavaScript in the href by typing JavaScript: in it see my example below:

    Try this:
    [code]
    Go to google

    [/code]
    ;-)
    -mac-
    mailto:mac_doggie@hotmail.com
    the Netherlands...


Sign In or Register to comment.