onclick on button
-
Hi.
Thank you for choosing our product.
Kindly specify exactly what you wish to achieve.Best regards,
SophiaI am not sure if I put it properly, but:
I need to include a script (or code) from the outer service. To do that I need to add some code to the page (I did it using “HTML code” element, but after that I have to assign a command:
onclick="K24('https://kregielnia24.pl/rezerwuj/98/bowling');"and apply that to any button..
-
This reply was modified 8 months ago by
elemeledutki.
Hi again
You can use Simple Custom CSS and JS plugin for that purpose, you have to declare mentioned function there and after that apply it to all buttonsfunction K24(url) {
window.location.href = url;
}
$(document).ready(function() {
$(‘button’).on(‘click’, function() {
if (typeof K24 === ‘function’) {
K24(‘https://kregielnia24.pl/rezerwuj/98/bowling’);
}
});
});
Kind regards,
GeorgeThank You, George.
I will need some step-by-stem instructions.
I installed the plugin and declared the function by using “Add custom JS” (I placed your code into the box). Upon saving – the plugin did a permalink (“https://qapqubqyvj.cfolks.pl/wp-content/uploads/custom-css-js/501.js“), but I dont know what to do next.
I tried to add a button and add the link above as a “link” in button properties, but it certainly did not work.
In fact – I will need to call that code from the menu bar.
Here are all the inctructions from the site owner:
Put the script anywhere on the page:
<script type='text/javascript' lanuguage='javascript'> function K24(URL) { var width = 999, height = 800,left = (screen.width - width) / 2,top = (screen.height - height) / 4; window.open(URL,'','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,copyhistory=0,width=' + width + ',height=' + height + ',top=' + top + ',left=' + left); }; </script>Once its done – apply the code below to any of the buttons you wish to use:
onclick="K24('https://kregielnia24.pl/rezerwuj/98/bowling');"Do You think you may help?
-
This reply was modified 7 months, 2 weeks ago by
elemeledutki.
Hi again,
Can you tell us is it some library to work along with or just separate function on it’s own ?
If it’s just function without any library needs you can place the code in custom js custom code created by you and then call it wherever needed, you can call it in the same file if you have specific selector for the button instead of ‘button’ general selector.
Don’t directly copy/paste script provided by us and also check url properly if it’s correctly unescaped, also can you tell us, script doesn’t work at all or is it showing some errors in devtools when you inspect the page after click ?
Kind regards,
George -
This reply was modified 8 months ago by
The topic ‘onclick on button’ is closed to new replies.