Simple Iframe Reload

Of course your first thought would be: use JavaScript. But there is no real need for that!

JS-less approach is to use target attribute of <a> to change src of iframe.

Example:

<a href="home.html" target="sub_page">Home</a>
<a href="goodies.html" target="sub_page">Goodies</a>
<a href="contact.html" target="sub_page">Contact</a>

<iframe src="home.html" name="sub_page"></iframe>

How it works

name attribute acts mostly like id. Except it specifically exists for iframe and as a way to refer it (e.g. by link)

When you click link, its target attribute determines how to perform switch to this link. When you specify target as iframe name, instead of changing current page, iframe will change its current page.

It is a hack

No, it is not a hack. Even though target is not supported in HTML5, it is gonna continue to work.

Though it is not very convenient as iframe has some limitations.

results matching ""

    No results matching ""