This a wordy problem, so I’ll try and be as specific as possible.
I have two wysiwyg text editors held within two separate containers. In a function run on onclick of an <a> tag, one container is slid up and inserted before the other container. This causes the wysiwyg box to completely break, so I remove it and then reinitialize it. The problem I’m having is getting the content within it.
This is the HTML structure of wysiwyg:
<div class="rightFieldContainer">
<div class="wysiwyg" style="...">
<ul class="panel" role="menu">...</ul>
<div style="clear: both;">...</div>
<iframe frameborder="0" style="..." tabindex="0">
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>...</head>
<body style="..." class="wysiwyg">
<b _moz_dirty="">WHAT I'M TRYING TO GET</b></strike><br>
</body>
</html>
<iframe>
... (all remaining tags are closed)
The path to the content is my function is specified as such:
var content = $("#someContainer1").find(".rightFieldContainer").children(" .wysiwyg").children()[2].contentWindow.document.body.innerHTML;
Using innerHTML returns a blank and html returns undefined. What’s more curious is that if I use the same/similar path to get the content of another textbox that is never meant to be moved, it works fine.
I understand that it’s impossible to hope for a clear answer since the problem itself is a little vague, but just an alternative to innerHTML or reasons why it might not work are appreciated. Thanks.
Content in an iframe is not navigable using selectors from the parent document. To get the document for the iframe you need to do:
.contents()gets the document for the iframe so you can then find things within it from the parent page, assuming that the contents of the iframe are on the same domain.To simplify this you should give your iframe a class/id and select it directly as such: