Skip to content Skip to sidebar Skip to footer

Is It Possible To Use JQuery To Load A Url Into An Iframe When A Link Is Clicked On The Same Page?

Solution 1:

That's what target attribute is for.

iframe { width: 100%; height: 50%; }
<iframe id="display" name="display"></iframe>
<br>
    <a href="http://jquery.com" target="display">Load</a>

Solution 2:

Is this what you want?

$('#url').click(function(e) {
    e.preventDefault();
    $('#display').attr('src', $('#url').attr('href'));
});
iframe { width: 100%; height: 50%; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<iframe id="display"></iframe>
<br>
    <a type="text" id="url" href="http://jquery.com">test</a>

Post a Comment for "Is It Possible To Use JQuery To Load A Url Into An Iframe When A Link Is Clicked On The Same Page?"