dispatchEvent in iframe

Discuss building things with or for the Mozilla Platform.
Posts: 1
Joined: December 21st, 2011, 4:06 pm

Post Posted December 21st, 2011, 4:21 pm

Hi, I am trying to do a slides viewer working with google doc.
I just put the doc link in a iframe a with prev/next buttons I want to control.
So the idea is to simulate key press : 'n' for next and 'p' for previous

Code: Select all
   <title>Slides viewer</title>
   <script type="text/javascript" src=""></script>
   <script type="text/javascript">
      $(document).ready(function() {
         $("#prev").click(function() {
         $("#next").click(function() {
      function pressKey(code){
         var evt = document.createEvent("KeyboardEvent"); // or KeysEvent
         // Send to label   
         var myLabel = document.getElementById('myLabel');
         // Send to slides
         var slides = document.getElementById('slides');

   <input id="prev" type="button" value="<"/>
   <input id="next" type="button" value=">"/>
   <input id="myLabel" type="input" value=""/>
       <iframe src="" id="slides"

I put a label just to verify events are well.
When I click on buttons, the label is fill but the slides don't change. However, if I just press 'n' or 'p', it's work because the iframe have focus.
Any idea ?

Posts: 8
Joined: July 16th, 2008, 6:30 am
Location: Vancouver, Canada

Post Posted June 4th, 2014, 5:15 pm


I've got a similar problem with .dispatchEvent(evt) on an element inside an iframe. Have you figured this out, please?


User avatar
Posts: 123338
Joined: September 23rd, 2004, 8:57 pm
Location: Somewhere on the right coast

Post Posted June 6th, 2014, 5:43 am

I doubt that nfr will answer after not following up on their original post of three years ago.

Locking this due to the age of the original posts. If you require support please create a new topic.

Return to Mozilla Development

Who is online

Users browsing this forum: No registered users and 0 guests