c# - Loading an Iframe With JQuery (Correct Method) - Stack Overflow

Which is the correct way to load an Iframe using JQuery?Actually I have a menu with several links and I

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.

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.

Share Improve this question edited Dec 17, 2016 at 12:37 Termininja 7,03612 gold badges50 silver badges50 bronze badges asked Apr 19, 2012 at 3:57 nothingInTheNamenothingInTheName 3134 silver badges11 bronze badges 2
  • What is the "some other problem" with it. The target method is correct and does not require JavaScript to work. Help if you showed the "several methods." – epascarello Commented Apr 19, 2012 at 4:12
  • I know target method is correct but it would be really helpful if you could tell me some method to do it by JQuery – nothingInTheName Commented Apr 19, 2012 at 4:14
Add a ment  | 

2 Answers 2

Reset to default 8

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>

$('#iFrameName').load('somefile.html');

This selects the iframe (you need id="iFrameName" or the like in the iframe tag) and loads a file into it. But, you can just use the target attribute on the a href.. I see you mention there are problems... what is your DOCTYPE of the html? What problems are you having with a basic a href?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742267829a4412136.html

相关推荐

  • c# - Loading an Iframe With JQuery (Correct Method) - Stack Overflow

    Which is the correct way to load an Iframe using JQuery?Actually I have a menu with several links and I

    1天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信