I wonder if there is a working way (compliant with most browsers) to show other pages inside a page which belongs to the same domain - I just learned IFRAMES do not allow this- they can only be used to show the content from external sites - right?
Dave
- they can only be used to show the content from external sites - right?
No. There is no restriction on the src attribute of <iframe>s (living standard - HTML 4).
If you're not particularly fond of how the current HTML standard offers information, have a look at MDN's page on <iframe>s - some find its format friendlier.
The main difference between <iframe> and any alternative is that the <iframe> acts like an independent page (it doesn't share resources with its parent document), while fragment / component / template loading is about creating placeholders in a document where contents from another file on the same server will be placed at parse time (so all scripts/styles in parent will apply to the fragment and any such resources loaded by fragment will also affect the parent).
Fragments / components / templates are now only possible through the use of libraries (most popular being jQuery's .load()) but will probably be possible as part of HTML once HTML Components will become living standard.
While some might feel I should have mentioned Shadow DOM here, it is only a special case of HTML Components, which encapsulates its styles and scripts so they do not apply outside the component and also provides a few handy methods to do it (:host, :host() and :host-context()).
Currently, Shadow DOM is a working draft and using it cross browser is only possible with webcomponents.js.
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