0

I am getting an iFrame this way currently:

$('body', window.parent.frames[0].document)

This is for CKEditor, the WYSIWYG html editor. However, I believe it dynamically adds certain other frames (not sure how). So I rather just get a specific frame by a class name that I know will always be there (unlike the above method which will only get the first instance).

The class name is: cke_wysiwyg_frame

How can I do this?

(The reason is I am saving the content to my database with a button; the button needs to know where the CKEditor content is. So far the way I am doing it is unreliable.)

Edit: I decided to do it the correct way using the Ckeditor API and not my requested hack above.

6
  • Why are you not using the CKEditor api to get the content? AKA CKEDITOR.instances.editorId.getData(); Commented May 1, 2014 at 18:42
  • window.parent.getElementsByClassName('cke_wysiwyg_frame') doesn't work? Commented May 1, 2014 at 18:43
  • The api seems to save using onblur when you click outside of the editable area which is not what I want. Commented May 1, 2014 at 18:44
  • What does onblur have to do with getting the data? Commented May 1, 2014 at 18:45
  • @epascarello it uses the getData() method like you said. I am not sure how to use that in the context outside of the way I saw in the docs which was event.editor.getData() I think. The event came inside a function which I am not using. Commented May 1, 2014 at 18:50

2 Answers 2

1

To get the value from an editor instance, you can reference the instance and use getData

CKEDITOR.instances.editorId.getData();
Sign up to request clarification or add additional context in comments.

Comments

0

Try this

$(".cke_wysiwyg_frame").contents().find("contentIdorClass");

You better use .contents() method to get all the content of the iframe.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.