Run JavaScript from an HTML Button Onclick Event
This is a solution to add a button anywhere on the page that would open a popup.
Step 1
Add an HTML component to your page, open its settings, and add the following code within the source code <> tab.
<div class="feedback" style="text-align: right;"><button id="feedback-btn" class="btn"> <img src="exclamation-mark.png" width="25px" height="25px" /> </button></div>
Step 2
Save the HTML component and hover over the info icon to get the component ID.
Step 3
Add the following code to the JavaScript tab of your page.
TB.render('component_ID', function(data) {
$('#feedback-btn').on('click', function() {
var url = "http://www.example.com";
var width = 960;
var height = 1040;
var left = screen.width - 400;
var top = 5;
var params = "width=" + width + ", height=" + height;
params += ", top=" + top + ", left=" + left;
params += ", directories=no";
params += ", location=no";
params += ", menubar=no";
params += ", resizable=no";
params += ", scrollbars=no";
params += ", status=no";
params += ", toolbar=no";
newwin = window.open(url, "customWindow", params);
if (window.focus) {
newwin.focus();
}
return false;
})
});
Remember to edit the code to your component ID and the URL you wish to display.
We'd love to hear your feedback.