You never defined receiveMessage
, instead you tried to use $.receiveMessage
. You're miss-using the jquery methods, you don't always need to wait for the dom to be ready. You also don't need jquery at all for this.
<script type="text/javascript">
window.addEventListener("message", receiveMessage, false);
//$(function () {
function receiveMessage(event){
if (event.origin == "http://origindomain.com" && event.data == "scrollTop") {
window.scrollTo(0, 0);
}
}
//});
</script>
If you installed a jQuery plugin that defines $.receiveMessage
, then you likely didn't need the first line at all because the plugin should take care of that. But, i'm not sure why a plugin would be needed for this functionality.