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%; }
<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?"