Tuesday, 11 March 2014

JavaScript_Frames



Basic frames

The HTML for basic frames could look like this:
<HTML>
  <FRAMESET cols="20%, 80%">
    <FRAME src="left.html">
    <FRAME src="right.html">
  </FRAMESET>
</HTML>
The HTML document which as frameset instead of body splits browser window in sections. In the example above, there are two of them.
The left one is 20% of width, it loads left.html, the right one is 80% and loads right.html.

The frameset element can be nested and provides several ways to split the window: either vertically or horizontally. Frames are allowed to contain frames. So, the browser window may be split into cells the way you like.
Each frame loads separate document. Reloading or navigation of a frame does not affect other frames.
* The basic frames are deprecated. The frameset tag and its helper tags frame/noframes are removed from the modern HTML5 standard.
Actually, basic frames are out of use by now. They are given here for historical reasons and completeness only. So, we’ll move forward to more advanced frames stuff which is really used.

Inline frames or iframes

Inline frames provide a way to embed another page as a rectangular sub window. For instance, here is an inline frame with top of http://javascript.info:
<iframe src="http://JavaScript. info"></iframe>

Removing the native frame border
To remove the border around the iframe in an IE-compatible way, it should be set as an attribute.
In the example below, the first frame is bordered by default, the second is unbordered using CSS, and the last one has frameborder="0" which will work for IE (including IE9).
Check this example in IE to see that only the last way works.
<ol>
  <li><iframe src="JavaScript: ‘content'"></iframe></li>
  <li><iframe src="JavaScript: ‘content'" style="border:0"></iframe></li>
  <li><iframe src="JavaScript: ‘content'" frameborder="0"></iframe></li>
</ol>
So, one usually sets frameborder="0" and applies custom border with CSS if needed.

Iframe src property

As you noticed in the example above, the src attribute may be either standard or JavaScript:.... In the latter case, the code is executed and the result is used as content.
Iframe without src
An iframe without src attribute is wild and awry.
It leads to problems in older browsers. In newer IEs it has problems with HTTPs: iframe without src gives non-secure warnings on SSL-enabled page.
The empty src="" won’t work, because it actually means to load the URL referenced by “”, that is the current page.
To create an empty iframe which works well on IE HTTPs, one should use src="JavaScript:''" syntax.

No comments: