Friday, February 5, 2016

How to change the src of a iframe without using Javascript

In some cases we may need to use certain links in a single page where we need to load the appropriate link location in the same page of the Ifame so here is how to so that with out using JavaScript

Give all your links with a specific target as shown here

<a href="home.html" target="ifme" >Home</a>
<a href="details.html" target="ifme" >Details</a>

then in the Iframe declare it with the name attribute with the same target value given

<iframe src="index.html" name ="ifme" />

By using the above you could redirect to a specific webpage given in the anchor tags that send the value (src) to the same page of the iframe.

LiveDemo : https://jsfiddle.net/3a0r8xrs/