I am writing a small web app and I would like to add a donation button by using the ko-fi donation widget button. The result is something like this:
My goal is to change it’s position for example by lowering the button to 5px.
I tried with some javascript but it looks like it only works if I do it from the browser console.
<script src='https://storage.ko-fi.com/cdn/scripts/overlay-widget.js'></script>
<script>
kofiWidgetOverlay.draw('federicogentile90', {
'type': 'floating-chat',
'floating-chat.donateButton.text': 'Support me',
'floating-chat.donateButton.background-color': '#fcbf47',
'floating-chat.donateButton.text-color': '#323842',
});
// WHAT I TRIED TO DO!
window.onload = function() {
let kofiElement = document.getElementsByClassName("floatingchat-container-wrap");
console.log(kofiElement);
// Modify bottom position
kofiElement[0].style.bottom = "5px";
};
</script>
Do you know how the widget can be moved around the html page please?
2
Answers
I was able to achieve my goal by using the following trick: instead of using the floating button provided by ko-fi, you can use the create a ko-fi button as an image so that when you click on it the donation panel opens up as a modal.
Here is what it looks like right now:
As you can see now the button is in the navbar but when I click on it the payment form appears on the screen.
Here is the code in case you need it:
Make sure to update the iframe with your ko-fi link!
Try this: