2

I have an iframe that looks like this:

<!DOCTYPE html>
<html>
<body>

<iframe src="http://www.w3schools.com" style = 'height:100px;width:200px;' scrolling = 'no'>
  <p>Your browser does not support iframes.</p>
 </iframe>

</body>
</html>

so when I press tab in the iframe, it traverses through all the links , automaticall scrolling all the way to the bottom of the site that's in the iframe. What I want to do is make the iframe so that tab only within the rectangle box where height = 100px, width = 200px and ignore everything else on the site...basically clip everything else that doesn't fit into this rectangle...

I tried setting height and width and also overflow:hidden, but that doesn't seem to do the trick.

Ashesh
  • 939
  • 2
  • 11
  • 28
  • Your code works on chrome and ie10. – Itay Gal May 07 '14 at 17:32
  • no but it tabs through everything on the w3schools site. what i want is for it to be only be able to tab through whatever is showing in the 200px X 100px window. any links on w3schools site that do not fall into this window should not be focused at all on tabbing. – Ashesh May 07 '14 at 17:35
  • Please provide a JSFiddle example, this http://jsfiddle.net/7ky5y/ seems to work – Itay Gal May 07 '14 at 17:37
  • Afaik the only way to affect tabbing order, is to set [`tab-index`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement.tabIndex). Since you've a [cross-domain page](https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy) in your `iframe`, there's nothing you can do. – Teemu May 07 '14 at 17:44

2 Answers2

0

This blocks user from being able to click on anything in the iframe but for some reason, you can still click inside and tab through :-( fiddle

<div id="IframeWrapper" style="position: relative;">
    <div id="iframeBlocker" style="position: absolute; top: 0; left: 0; width: 400px; height: 200px"></div>
    <iframe src="http://www.w3schools.com" style='height:200px;width:400px;' scrolling='no'>
        <p>Your browser does not support iframes.</p>
    </iframe>
</div>
MilkyTech
  • 1,919
  • 2
  • 15
  • 39
0

You can't do anything about it, but instead you can run a JS on iframe load which cam hide the html contents from your iframe which you don't want to be displayed

you can refer to these similar questions to get the idea:

  1. Changing div in iframe using Jquery
  2. jQuery, select element inside iframe, which is inside an iframe

And there's a similar discussion on jQuery forums here: https://forum.jquery.com/topic/changing-elements-in-an-iframe

Community
  • 1
  • 1
Saurabh Sharma
  • 2,422
  • 4
  • 20
  • 41