jackmoore / colorbox

A light-weight, customizable lightbox plugin for jQuery
http://www.jacklmoore.com/colorbox/
MIT License
4.75k stars 1.14k forks source link

iframe focus #884

Open clomaka opened 4 years ago

clomaka commented 4 years ago

I'm adding arrow key navigation to my iframe html, but the code only works after i click somewhere inside the iframe first. Is there some way to force focus on the iframe on load or on complete?

(btw, i have iframe and inline both set to true, just in case that'swrong)

clomaka commented 4 years ago

so far, i'm solving it like most other ppl - adding a button at the top: button id="focalpoint" "x"<"/button"> and adding that id to the called url: <a class='iframe' id="portfolioframe" href="portfolio_Halo5_01.html#focalpoint"><img class="image" src="img/TH_Halo501.jpg"></a>

I tried adding a div id to the url, but that didn't work for some reason, so i'll stick with a 1px button w. an id.

jackmoore commented 4 years ago

My apologies for the late reply. I wasn't sure how to address this, so I'm glad you are finding a way. That sounds like a very good option. I figured you could use the onComplete callback to select the iframe contentWindow and focus, but I believe that has to wait until the iframe's onload event fires, which is not something I would want to wait on if I could avoid it.