Is It Possible To Use Jquery To Load A Url Into An Iframe When A Link Is Clicked On The Same Page?
Is is possible using JQuery to load the src of an tag into an iframe on the same page as the linked clicked if you can not edit the html? Something similar to this but i
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?"