Uservoice asks you to load async their widget on page load which the code looks like this:
var uvOptions = {};
(function() {
var uv = document.createElement('script'); uv.type = 'text/javascript'; uv.async = true;
uv.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'widget.uservoice.com/loremipsum.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(uv, s);
})();
And then they give you the option to run their widget on click as such:
javascript:UserVoice.showPopupWidget();
What if I dont want to load their widget once the page is loaded at all only when the user clicks on the link?
I would assume something like this:
$('selector').click(function () {
var uvOptions = {};
(function() {
var uv = document.createElement('script'); uv.type = 'text/javascript'; uv.async = true;
uv.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'widget.uservoice.com/cyoJokWhM5SEW9I3h3oBFQ.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(uv, s);
})();
javascript:UserVoice.showPopupWidget();
});
But it doesnt actually work? is there any other known way?