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%; }
<iframeid="display"name="display"></iframe><br><ahref="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%; }
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><iframeid="display"></iframe><br><atype="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?"