开发者

adding text into iframe with jquery

I have an HtmlEditor from asp controltoolkit.

That creates an iframe with a couple things i need (bold letter, etc).

I need to开发者_运维技巧 add text to that iframe with jquery.

so long i have this.

$('#<%= tbDescripcionInsert.ClientID %>').contents().text(textoMercancia.substring(15, textoMercancia.length));

My problem is that the things im using from the editor (bold letter etc) disappear when i add the text from jquery.

What can it be?

What is the best way to add text into an iframe with jquery?

Thank you very much.


If you want to handle markup, not just text, use html() instead of text().


the problem is that

  .text('blahblah') 

replaces the text so you must use

 .append('blahblah') 

or some similar command

EDIT seeing your post this might be more effective

  $('#<%= tbDescripcionInsert.ClientID %>').contents().find('body').append('blahblah')


Try something like:

var d = $("#someFrame")[0].contentWindow.document; // contentWindow works in IE7 and FF d.open(); d.close(); // must open and close document object to start using it!

// now start doing normal jQuery:

$("body", d).append("ABC");


Thank you all for your help.

I found a way to solve this:

$('#<%= tbDescripcionInsert.ClientID %>_ctl02_ctl00').contents().children().children('body').html(textoMercancia.substring(15, textoMercancia.length));

this way i can access the exact part of the iframe where the information is supossed to be loaded. hope this help someone in the future.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜