• Hi

    I want to thank you for this plugin. I use this plugin on a website to make some nice buttons with external links to other website on them. I want to keep the url but I want to add also javascript onclick events. Is this possible? Thank you a lot!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter andreipol

    (@andreipol)

    I want to mention that my javascript function is in the header of my website. After clicking the button I want to execute my javascript code and also go to external URL.
    The onclick event would be the same on all buttons, only the links would be different
    Or tell please where in the files of the plugin to add onclick=”myFunction();” to appear after the url introduced on every button

    • This reply was modified 7 years, 10 months ago by andreipol.
    • This reply was modified 7 years, 10 months ago by andreipol.
    Plugin Author Bas Schuiling

    (@basszje)

    Hi,

    You can’t do both at the same time, the browser has to decide then if it should go to the URL or run the javascript function and both will work unreliably.

    What you can do however is hook the javascript function to the button and then let the JS function do the redirect to URL.

    In the URL field of the button you can enter the javascript function :

    javascript:myFunction();

    or even pass the URL there

    javascript:myFunction('https://');

    and then have a JS function:

     function myFunction(url) {
      [ stuff to do here ] 
    window.location = url; 
    }
    
    Plugin Author maxfoundry

    (@maxfoundry)

    @andreipol is this issue resolved?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Run Javascript Onclick but keep also url link’ is closed to new replies.