javascripthtmlzendesk

Activate ZenDesk widget using JavaScript trigger


Okay so I am editing a page here support.tophat.com and at the bottom left of the screen there is a little widget button that opens up a handy little support ticket window upon click. This is the ZenDesk widget that is provided by zendesk to provide a service for customers to submit support tickets to the ZenDesk back end.

What I'm trying to do is to include an "onClick" call to a function on some arbitrary link or button elsewhere on the page that will trigger the support ticket window to display, without actually having to click on the button in the bottom left.

It would seem that this is through an iframe, and I have already tried the jQuery .click() function to no avail... After inspecting the element, and seeing what function gets fired when a user clicks on the button, I get a long string of disgustingly cryptic JS that has no real outlined functions.

My end goal is to open the support window after clicking on, lets say, a link that has a trigger like if I click on a link, and set the onClick="trigger()" which fires the window to open in the bottom left.

If you would like me to include the block that chrome shows be when the event is fired let me know, but it is NOT pretty and mods might not like if i put in code that looks like that.


Solution

  • Using jQuery (which is included in the Zendesk Help Center), you can do this:

    $('#launcher').contents().find('.Button--launcher').click();
    

    I tested it out on your site in the Chrome console, and it activates the widget.

    I found info relating to this answer here: IFrame button click event

    Info on jQuery's .contents(): https://api.jquery.com/contents/