What is the <Frameset> tag for?

Asked

Viewed 563 times

0

I was reading this topic on the Mozilla page, and a piece caught my eye:

Returns the element <body> or the <frameset> of the current document, or null if none of these elements exists.

The link to <frameset> was absent, so I searched a little, but the sites I found confused me more that explained.

This, for example, in a given passage, says:

This means that we will no longer use the tag body, [...]

Why document.body can return <frameset>? And why the <frameset> would replace the <body>? What he is, in practice?

  • 1

    This tag was deprecated with Html5, it was used to render an html inside another, the Mozilla page without translation seems to be better: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/frameset

  • 1

    @Danielmendes "depreciated"

1 answer

1


The element <frameset> is valid in the DTD HTML Frameset as I have explained in:

Example of use:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
   "http://www.w3.org/TR/html4/frameset.dtd">

Note that the tags and this way of creating pages is obsolete:

It should be avoided and a good suggestion in this answer:


The "HTML DTD Frameset"

The DTD helps the browser to determine behavior, of course the browser "tries" to determine without the DTD (DOCTYPE Document), so probably in a document with Frameset other tags would be ignored, unless the browser is too old and does not support frames (but it’s talking a lot about the past), so if you do this for example:

<head>
<title>exemplo de iframe</title>
</head>
<frameset cols="20%, 80%">
  <frameset rows="100, 200">
      <frame src="contents_of_frame1.html">
      <frame src="contents_of_frame2.gif">
  </frameset>
  <frame src="contents_of_frame3.html">
  <noframes>
      seu navegador não suporta frames
  </noframes>
</frameset>
<script>
document.addEventListener("DOMContentLoaded", function () {
    console.log('body', document.body);
});
</script>

If you test will notice that the tag <script> does not process Javascript and is also not rendered and does not appear in inspector of elements, Now if you put yourself inside HEAD it will work:

<head>
<title>exemplo de iframe</title>
<script>
document.addEventListener("DOMContentLoaded", function () {
    console.log('body', document.body);
});
</script>
</head>
<frameset cols="20%, 80%">
  <frameset rows="100, 200">
      <frame src="contents_of_frame1.html">
      <frame src="contents_of_frame2.gif">
  </frameset>
  <frame src="contents_of_frame3.html">
  <noframes>
      seu navegador não suporta frames
  </noframes>
</frameset>

So the main element in this type of document is even Frameset, the main one being that there cannot be elements on the same level (except the <head>) because this is the goal of Frameset, to be the subdivision of a window (window Subdivision), as described in:

<![ %HTML.Frameset; [
<!ELEMENT FRAMESET - - ((FRAMESET|FRAME)+ & NOFRAMES?) -- window subdivision-->
<!ATTLIST FRAMESET
  %coreattrs;                          -- id, class, style, title --
  rows        %MultiLengths; #IMPLIED  -- list of lengths,
                                          default: 100% (1 row) --
  cols        %MultiLengths; #IMPLIED  -- list of lengths,
                                          default: 100% (1 col) --
  onload      %Script;       #IMPLIED  -- all the frames have been loaded  -- 
  onunload    %Script;       #IMPLIED  -- all the frames have been removed -- 
  >
]]>

Hence there is no BODY in it, and the use of document.body to obtain the frameset is mere convention.

Note that in the HTML4 doctype this is indicated:

<!-- Feature Switch for frameset documents -->
<!ENTITY % HTML.Frameset "IGNORE">

Which states that the document (the page) should change to the framesets format and only the Frameset tag is indicated and when it is not the case it uses this given structure:

<!--================ Document Structure ==================================-->
<!ENTITY % html.content "HEAD, BODY">

The content of HTML "may" contain HEAD and BODY (not being obliged, of course browsers also try to compensate and not always the engine will follow "the letter")

Browser other questions tagged

You are not signed in. Login or sign up in order to post.