How can I open a link (any link) within a certain DOM object in the current page, that is, display the link target’s content inside that very DOM element. I would like to do something that would be achieved using an <iframe> element if it were in the old days, but since <iframe> is going to be obsolete, I want do it without it.
How can I open a link (any link) within a certain DOM object in
Share
If I understand you correctly, you’d like to load a new page inside of an existent DOM object inside your page, for example a
<div>. If so, I would assume that this is simply not possible without using an iframe, because every other way you’d have to add content to your current document, which would not display correctly as it is not valid to nest<html>tags, and you’d have to execute foreign JavaScript on your own page, and you’d have to replace your own CSS and so on.Also, at least if you are trying to display a page that does not lie inside your own domain, you wouldn’t be able to fetch its content with pure JavaScript because of the same origin policy implemented by most (all?) browser JavaScript engines.
Also, iframes are not really deprecated (anymore? they were only deprecated for the
strictversions of HTML4 and XHTML), as you can read here: Are IFrames (HTML) obsolete? They’re back in HTML5 🙂