Reputation: 67
I want to develop a website to test an other websites script.
In the website (iFrame) that I want to test i have the following event listener:
$(document).ready(function(e){
$(document).keypress(HandleKeyPress);
});
Now I want to trigger a keypress event from my testpage (parent) to test the event listener.
I tried this:
var _window = $("#test-container")[0].contentWindow;
...
...
var evt = $.Event("keypress");
evt.charCode = char.charCodeAt(0);
$(_window.document).trigger(evt);
But nothing happens?!?!
Upvotes: 2
Views: 824
Reputation: 719
This is how you target a parent document
var parentDoc = window.parent.document
Once you have access to the parent document object, you may try whatever you want. and the jquery instance could be found as below
var parentDoc = window.parent.$
Let me know if this helps.
Upvotes: 1