Hi,

I give up, went through all the examples, but I still canot figure it out how can I add one script into head tag.

Starting like this:

tinyMCE.activeEditor.selection.setContent(tinyMCE.activeEditor.dom.createHTML('script', {type : "text/javascript", src : "some_url"},""));

It doesnt work.

What is even more interesting: just alerting head_node variable after first line returns me some giberish not visible in editor->source code..

Any quick help?

Why not this?

editor.dom.add(
// node(s)
// tag name
"script",
// attributes and their values
{
src: "some_url",
type: "text/javascript"
}
);

I haven't tested this though...

Greetings from Germany,

Felix Riesterer.
-- I am neither Moxiecode nor Ephox! --

Wau, if this actually works, I'm gonna bite my ass off on monday!!

Will test when I get back to that computer on monday and will let you know.

Thanks for now.

Hi,

bad news: this doesnt work. I knew it was too easy:D

Any idea what else could go wrong?

Can you create a fiddle to showcase your problem?

As for the script I've given you, editor.dom.select() returns a collection (like an array). You would need to take the first element of it:

editor.dom.add(
// node(s)
// tag name
"script",
// attributes and their values
{
src: "some_url",
type: "text/javascript"
}
);

I've created a fiddle on my own - check it out!

Greetings from Germany,

Felix Riesterer.
-- I am neither Moxiecode nor Ephox! --

Nope, even your fiddle doesnt work for me..

I arranged it a bit, does this work for you?
http://fiddle.tinymce.com/y4eaab/2

subjectx wrote:

Nope, even your fiddle doesnt work for me..

You mean, just because the code editor dialog doesn't show the script element even though it's in the DOM? I've checked using Firebug: It's there!

Maybe some cleanup logic removes it onsubmit and when the code editor displays the supposed "code"?

Greetings from Germany,

Felix Riesterer.
-- I am neither Moxiecode nor Ephox! --

Currently I have stuff put into script tags into body, which is ugly..

Will try to fiddle with your solution, but I doubt it will work, since when I do that with body tag it works and it shows, nothing shows with head tag.

Also like I mentioned earlier, with head tag (showing in code viewer or not) my script doesnt want to work, like its not there..

cant give you direct example, because stuff is across few files and its intern thing, no access from outside to this functions..

Last edited by subjectx (2014-11-25 10:42:10)