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 .asp")
    return;

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

Any help would be great! Thanks!

1 Answer 1

1

Looks OK, except you need $("#searchcrew") instead of $("searchcrew").

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.