jeudi 27 mars 2014

Cross Domain communication with iframe - to scroll to top


Vote count:

0




So I need a button(submit) withing the iframe to trigger the parent page to scroll to the top.


Here is what I have so far:


The iframe..



$(function () {
$("searchcrew").bind('click', function (event) {
window.postMessage("scrollTop","#domain of parent page");
});
});


The button in the iframe...



<input id="searchcrew" name='NavAction' type='submit' class="form_1" value='Search'> </div>


The parent page...



window.addEventListener("message", receiveMessage, false);

function receiveMessage(event)
{
if (event.origin !== "#domain of iframe")
return;

if (event.data == "scrollTop"){
window.scrollTo(0,0);
}
}


Any help would be great! Thanks!



asked 16 secs ago






Aucun commentaire:

Enregistrer un commentaire