English 中文(简体)
j Query - Case if text are within an iFrame
原标题:jQuery - find if text exists inside an iFrame

I m using an jQuery wysiwyg editor plugin on one of my textareas inside a form and I want o apply validation to it. The wysiwyg jQuery plugin is generating an iframe so I need to detect if there is any text inserted inside the iframe not the text area.

<div class="wysiwyg" style="width: 581px;">
<ul class="panel" role="menu">
<div style="clear: both;"></div>
<iframe id="id_message_bodyIFrame" frameborder="0" src="javascript:false;" style="min-height: 170px; width: 573px;" tabindex="0">
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body style="margin: 0px;">
my text I want to find if exists
<br _moz_dirty="">
</body>
</html>
</iframe>
</div>
<textarea id="id_message_body" title="Please add a message on the text box above." name="message_body" cols="70" rows="10" style="display: none;"></textarea>
<div id="req_message_body" class="req" style="display: none;">This is required</div>
</div> 

任何想法,如何确定在iframe中是否插入案文,并在其后形成一个错误信息,如<div id=“err”> 这个领域需要加固;/div>? 我赞赏你的帮助!

最佳回答
$( #id_message_bodyIFrame ).contents().find( body ).text()

that will give you text then you can just add

.length() 

直至最后测试时间

问题回答

暂无回答




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签