There's a web page where I'm trying to use Tampermonkey to give focus to an element in an iframe which is cross-origin to the top document. Copious use of console.log()
tells me that my script is executing, getting the proper element, and calling focus()
or click()
on it, but the component isn't scrolling when I press space; I have to manually click on the element for it to scroll from keyboard input (the page is otherwise responding to keyboard input just fine). I used "inspect" on the element I want and then entered $0
into the console to make sure that I referring to the correct element in my script. I even have my Tampermonkey script use the setTimeout()
trick, with a timeout of 1 second, but that's of no help.
A few other things of note:
- While the page is loading I can scroll up and down using the arrow keys, but as soon as it finishes loading it won't respond to those keys again until I click the element with my mouse.
- If I click on the element, press
Tab
to give focus to the next element, then pressShift-Tab
to cycle backwards, the result is that there's that thin blue outline around my desired element, seeming to indicate that it has focus, yet pressing space or the arrow keys won't scroll it.
I'm using Chrome 68.0.3440.106
EDIT: The pages in question are rented books from VitalSource viewed with their in-browser book viewer. Unless you already have a book with them that's currently valid you won't be able to view the problem pages.