Reputation: 1
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 .asp")
return;
if (event.data == "scrollTop"){
window.scrollTo(0,0);
}
}
Any help would be great! Thanks!
Upvotes: 0
Views: 1091
Reputation: 169
Looks OK, except you need $("#searchcrew") instead of $("searchcrew").
Upvotes: 1