do you know how I can get the outer window to hear the message coming from the iframe url? I also tried sending a message from the outer window url to the iframe then back to the outer window url. I can't get the outer window url to hear a message.Code:// ==UserScript== // @name return hit from iframe with keydown - RI Services hits // @namespace http://your.homepage/ // @version 0.1 // @description enter something useful // @author turker // @grant none // @require http://code.jquery.com/jquery-latest.min.js // @include * // ==/UserScript== if ( $("body:contains('Can you complete this task?')").length ) { document.getElementsByTagName("body")[0].onkeydown = function(event) { if (event.keyCode == 219) { //bracket key "[" returns hit from queue alert("test keydown from iframe url"); var returnHit = "yes"; window.opener.postMessage({A: returnHit},'*'); } }; } if (window.location.href.indexOf("https://www.mturk.com") > -1) { alert("outer window url first loaded"); window.addEventListener("message", listener, false); } function listener(l){ var info = l.data; alert("message getting through from iframe to outer window url"); document.getElementsByTagName("a")[0].focus(); }
Log in or register now. to view Spoiler content!