.......
Code
function listenForShare() {
if (window.addEventListener) {
window.addEventListener('message', onShare, false);
} else {
window.attachEvent('onmessage', onShare);
}
}
function onShare(e) {
var args = e.data.split("$");
if (args[0] == "ok_shared") {
alert(args[1]); // Вывод идентификатора фрейма кнопки - в случае нескольких кнопок на
одной странице, по нему можно определить какая именно была кликнута
}
}
listenForShare();
<div id="ok_shareWidget"></div>
<script>
!function (d, id, did, st) {
var js = d.createElement("script");
js.src = "http://connect.ok.ru/connect.js";
js.onload = js.onreadystatechange = function () {
if (!this.readyState || this.readyState == "loaded" || this.readyState == "complete") {
if (!this.executed) {
this.executed = true;
setTimeout(function () {
OK.CONNECT.insertShareWidget(id,did,st);
}, 0);
}
}};
d.documentElement.appendChild(js);
}(document,"ok_shareWidget","http://dev.ok.ru","{width:125,height:25,st:'oval',sz:12,ck:1}");
</script>