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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With