0

When the user's browser opens an embedded .pdf document, I shift the focus into that document, so the user can navigate backwards or forwards through the document using the keyboard: up-arrow, down-arrow, Home, End, Pgup, Pgdn.

To shift the focus, I use the following javascript, called by the onload event-handler of the frame in which the document is embedded:

/* if the frame is an <iframe> element,
   focus shifts in all browsers EXCEPT IE Explorer & Microsoft Edge */
/* if the frame is an <embed> element,
   focus shifts ONLY in Firefox */
/* the alert never fires */

function embedFocus() {
 var embedFrame = document.getElementById("embedFrame");

 if (embedFrame && embedFrame.focus) {
  embedFrame.focus(); }
 else {
  alert('embedded frame has no focus method'); }
}

What do I need to change to get Microsoft Edge and IE Explorer to shift the focus into a document embedded in an iframe element?

ardeley
  • 11
  • 2

1 Answers1

0

Perhaps like this:

document.all.MY_ELEMENT_ID.focus();

suchislife
  • 4,251
  • 10
  • 47
  • 78