Just recently I needed to make a Google Talk chatback session start automatically, that a website could offer assistance after x amount of idletime and start the chat upon request. Far cleaner than asking them to click a link, I wanted the session to initiate once a user click “Yes, start live chat!” (or something to that effect).
The problem, was the Google Talk chatback badge uses an iFrame. I wanted to use jQuery to click the “open” link, but because of cross-domain scripting security within browsers this wasn’t possible.
My solution was quite simple. First of all I realised that I could easily grab the source to my chatback badge.
$ wget "http://www.google.com/talk/service/badge/Show?tk=...&w=200&h=60" -O talkBadge.html
Then I modified the talkBadge.html file to fix the broken resources. I did this with vim, since I already had it open, but you can do it with any tool using a simple search and replace.
This replaces “/talk/ with “http://www.google.com/talk/. Finally I modified line 56 to give the a tag id=”talkLink”.
Now it was as easy as including the iFrame to my page as usual, but with the new talkBadge.html.
<iframe id="talkBadge" src="talkBadge.html" frameborder="0" allowtransparency="true" width="200" height="60"></iframe>
I used the setTimeout function and a jQuery UI Dialog box to build a quick “Do you require assistance?” alert. Works a treat.