2013-04-29 72 views
0

荫使用iframe从父这样如何使用Jquery将文本分配给iFrame中的标签?

<div id="Omit" class="Omit" style="display:none"> 
     <iframe src="Omission.aspx" width="1000" height="600"></iframe> 
    </div> 

在我Omission.aspx亚姆有一种标签,我收到显示我的Child.aspx有两页Parent.aspx和Child.aspx

荫从父值在标签,以显示

<div class="Right"> 

     <p> 
      <strong style="color: #000;">Omit</strong> 
      <asp:Label ID="lblOne" runat="server" CssClass="lblOne" ClientIDMode="Static" ></asp:Label> 

     </p> 
    </div> 

这里时,我指定文本标记IAM没有得到

var Text = $(".ddlName option:selected").text(); //Dropdwon of Parent.aspx 

我需要被分配到标签是在I帧 我已经试过这些方式作为

$(".lblOne").text($(".ddlService option:selected").text()) 
    $(".lblOne").text(Text); 
    $('#<%= lblOne.ClientID %>').html(Text) 
    $('#<%= lblOne.ClientID %>').text(Text) 

荫无法兵文本到标签.., 任何人都可以请帮我从这个这个值小的情况分配的, 谢谢Advace

+0

看看这个回答我的:http://stackoverflow.com/questions/15884994/javascript- can-data-be-passed-bi-directionalally-through-an-iframe/15928562#15928562它稍微有点多,然后你需要,但可能你需要更晚。 – 2013-04-29 07:07:30

+2

Duplicate:http://stackoverflow.com/questions/364952/jquery-javascript-accessing-contents-of-an-iframe – 2013-04-29 07:10:18

+0

@ t.niese但是,这里我没有分配iframe的Jquery我只是想分配文本到标签这是iframe的另一页 – 2013-04-29 07:11:32

回答

2

试试这个:

// Get the iFrame jQuery Object 
var $MyFrame = $("#iframeid"); 

// You need to wait for the iFrame content to load first 
// So, that the click events work properly 
$MyFrame.load(function() { 
    var frameBody = $MyFrame.contents().find('body'); 

    // Find the label 
    var $label = frameBody.find('.lblOne'); 

    // Set the label text 
    $label.html(Text); 
}); 
+0

是的,它的工作 – 2013-04-29 07:21:22

相关问题