Cant see split html file - html

I'm trying to split html file into 2 different files:
<html>
<head>
</head>
<body>
<frameset cols="25%,75%">
<frame src="addNewEvent.html" />
<frame src="totalEvents.html" />
</frameset>
</body>
</html>
addNewEvent.html:
<html>
<head>
</head>
<body>
Left
</body>
</html>
totalEvents.html:
<html>
<head>
</head>
<body>
Right
</body>
</html>
The 3 files (main html and addNewEvent.html, totalEvents.html) are in the same directory.
(I just learning html, so for now, I'm not using server, and open the main page with the browser.
When opening the main page in the browser, is seems that the addNewEvent.html, totalEvents.html are not loaded. (There is no error in console log)
What an I doing wrong ?
Is it right to split the page into little pages with frameset ?

What an I doing wrong ?
You didn't use a validator which would have told you that a <frameset> element is not allowed inside a <body> element.
Frameset documents have a <frameset> instead of a <body> element. Since the HTML document already had its own <body>, the browser ignored the <frameset>.
Is it right to split the page into little pages with frameset ?
That's largely a matter of opinion. They do cause various issues with how they interact with browser navigation controls and do not exist in HTML 5.

Related

Can I put an entire HTML document in a template?

I want to store an entire HTML document to put in an iframe (srcdoc) later.
Am I allowed to put everything in a template including the html, head and body like this?
<template>
<html>
<head>
<title>Document</title>
</head>
<body>
<main>Content</main>
</body>
</html>
</template>
If not, what's the best way to store an entire document? Thanks!
Unfortunately, the template tag is not allowed to contain <html> tags. per 4.1.1 of the HTML specification:
Contexts in which [the <html>] element can be used:
As document's document element.
Wherever a subdocument fragment is allowed in a compound document.
and from 4.12.3, the <template> tag does not provide either of these contexts. For the same reason, you can't use <head>, <body> or <title> tags either. Chrome and Firefox both actively strip out the invalid tags from the <template>, preventing you from using it.
The best way of storing HTML for use in iframes is to put the HTML code in a different file in your web server.
However, an acceptable alternative is to store the HTML inside your <iframe>, then populating the srcdoc attribute with the content.
<iframe id="yourIframe">
<!-- Everything inside here is interpreted as text, meaning you can even put doctypes here. This is legal, per 12.2.6.4.7 and 4.8.5 of the HTML specification. -->
<!doctype html>
<html>
<head>
<title>Document</title>
</head>
<body>
<main>Content</main>
</body>
</html>
</iframe>
...
<script>
...
const iframe = document.getElementById("yourIframe");
iframe.srcdoc = iframe.innerHTML;
</script>

Can't embed contents using iframe

Here is the short simple HTML5 code that defines my page:
<!DOCTYPE html>
<html>
<head>
<title>My Site</title>
</head>
<body>
<iframe src="2.html" width="450" height="350"> </iframe>
</body>
</html>
I have triple-checked that file 2.html exists in the same directory, and it has some code in it. I have cleared caches and history in my browser, but observed no page embedded. I have tried this in Chrome, Firefox and IE too, but am getting nothing. I just got the iframe box with border, that's completely white (blank). What's wrong with it?

unable to load html page into a frame tag

I'm trying to segment the total window into 2 frames.In those two frames I'm trying to load the html page.I'm able to segement an entire window into frames but unable to load a html page within that frame.
My test.html:
<!DOCTYPE html>
<html>
<head>
<title>HTML Target Frames</title>
</head>
<frameset cols="200, *">
<frame src="/home/divya/html_docs/current/menu.html" name="menu_page" />
<frame src="/home/divya/html_docs/current/main.html" name="main_page" />
<noframes>
<body>
Your browser does not support frames.
</body>
</noframes>
</frameset>
</html>
Can anyone suggest me about this issue ...
You are putting absolute server paths of the files.
In your case you will get then:
http://yourdomain.com/home/divya/html_docs/current/menu.html
put there urls relative to your test.html file. like: src="current/menu.html"
or if the files are in the same directory just src="menu.html"

Multiple CGI scripts in an HTML frameset

I have multiple (3-4) CGI scripts which should be presented on one HTML page.
I tried this:
<html>
<head>
<title>Testing</title>
</head>
<body>
<h1>TESTPAGE<BR></h1>
<frameset cols="35%,20%,*">
<frame src="./cgi-bin/1.cgi">
<frame src="./cgi-bin/2.cgi">
<frame src="./cgi-bin/3.cgi">
</frameset>
</body>
</html>
Only TESTPAGE is shown, no cgi was opened.
Your HTML is invalid. A validator would have told you what the problem was.
You can't have a <frameset> inside a <body>. You use a <frameset> instead of a <body>.
When your browser encounters the <frameset>, it is already rendering a normal HTML body, so it ignores it because it has no place to put it.

Do `id` attributes need to be unique across iframes?

For instance, is this valid?
<!doctype html>
<html>
<head>
<title>Some Iframes</title>
</head>
<body>
<iframe id="frame1" src="/html/test-frame.html"></iframe>
<iframe id="frame2" src="/html/test-frame.html"></iframe>
</body>
</html>
Where the file test-frame.html has the contents:
<!doctype html>
<html>
<head>
<title>Test Iframe</title>
</head>
<body>
<button id="subscribe">Subscribe</button>
</body>
</html>
I would like to be able to use the same html and the same scripts for a set of iframes.
That's acceptable and valid. As each page is self-contained and therefore has its own individual namespace and DOM, there's no harm in using the same ID across iframes as long as it only occurs once within each iframe document.
Each page inside of an iframe is totally self-contained and unique.
You can have a page and 4 iframes, and each one can have an element called "#the-element".
Of course, the code that you have there is invalid, but if each loaded its own separate HTML, that would be perfectly acceptable.