Which is the correct way to load an Iframe using JQuery?
Actually I have a menu with several links and I want to load each link into The Iframe whenever user clicks on it. I am working on an ASP.NET website with my default page having this menu and Iframe both inside it.
I used Target="IframeName" but I dont want this method due to some other problem with it.
So Please tell me how to create a JQuery function to load such an Iframe. I searched for it and I Found several methods but no one seems to be working and I am struck with it , Moreover I am not able to understand which one is right.
The Iframe HTML Code
<iframe id="myIframe" name="myIframe"></iframe>
jQuery
jQuery("#myIframe").attr("src","newPage.html");
JavaScript
document.getElementById("myIframe").src = "newPage.html";
HTML link
<a href="newPage.html" target="myIframe">FOO</a>
Form submission
<form action="newPage.html" target="myIframe">
<input type="submit" name="btnSubmit" value="clicky"/>
</form>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With