iframe - Adding jquery event listener for google translate -
i'd perform jquery function after translates site different language using google translate dropdown. here's have tried no luck:
$('document').ready(function () { $(".goog-te-menu-value").change(function() { alert("my code working!"); }); });
on normal dropdown work fine, i'm having trouble targeting google translate div.. believe in iframe. there anyway target div thats in iframe use in jquery? or maybe workaround? if has ideas on appreciated.
i added google translate widget site , of course, broke layout!
so reviewed scripts used widget.
first, cannot add event listener button because google translate widget has 1 assigned.
second, discovered after translates, gt widget sets tag have class.
so, gave tag id of "docstart" , created following script.
note: breaks firefox v. 21, works in ie 9. haven't tested in other browsers.
function layoutfix() { // code here fix layout mylistener(); }; function waitforgoogle() { settimeout (function mylistener() { var e = document.getelementbyid('docstart').classname; var l = e; window.setinterval(function() { var cn = e.classname; if (cn !== l) // call function fix layout on class change layoutfix(); // set 10 second iteration },10000); // set 10 second wait gt widget load },10000); } // finally, load listener on document.ready() $(document).ready(waitforgoogle);
Comments
Post a Comment