Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Issues with PopUps and innerhtml

Status
Not open for further replies.

jrottman

Programmer
Jun 17, 2005
47
0
0
I am working on a plugin for tinymce and I have run into one little snag. The plugin I am working on is an advanced preview plugin. When the user clicks the preview icon, it pops up a new window. Normally I would get the content from the editor from the popup. However I am using coldfusion to generate a pdf print view of the content the user has entered. Since pdf's will not parse javascript code, I am forced to do it another way.

what I am trying to accomplish is when the user clicks the preview button, it populates the popup from the parent instead of the child. As of yet, everything I have tried has failed. I end up with this error every time.

win.document.getElementById("pvData") has no properties

Here is the code I am using to create my popup and attempting to populate the popup window. Everything works right up until I get to this point win.document.getElementById("pvData").innerHTML = tinyMCE.getContent();

Any help with this is greatly appreciated.

switch (command) {
case "mceAdvPreview":
file = 'tinymce/jscripts/tiny_mce/plugins/advpreview/preview.cfm'; // Relative to theme
var win = window.open(file, "mceAdvPreview", "menubar=no,toolbar=no,scrollbars=yes,resizable=yes,left=20,top=20,width=1024',height=768");
win.document.getElementById("pvData").innerHTML = tinyMCE.getContent();
return true;
}
 
You can do it like this.

[1] Make win global by not var it in the function, rather, var win; at the top level (or no var at all). Also prepare to make the tinyMCE global too, otherwise replace it with the complete reference path to the plugin thing. Make a separate function to load the win up. Like this.
[tt]
function loadContent() {
if (win.document && win.document.getElementById("pvData")) {
win.document.getElementById("pvData").innerHTML=[blue]tinyMCE[/blue].getContent(); //make sure tinyMCE well-defined here
} else {
setTimeout("loadContent()",20);
}
}
[/tt]
[2] The script fragment becomes this.
[tt]
switch (command) {
case "mceAdvPreview":
file = 'tinymce/jscripts/tiny_mce/plugins/advpreview/preview.cfm'; // Relative to theme
[red]//[/red]var win = window.open
(file, "mceAdvPreview", "menubar=no, toolbar=no, scrollbars=yes, resizable=yes, left=20, top=20, width=1024', height=768");
[highlight]win[/highlight] = window.open
(file, "mceAdvPreview", "menubar=no, toolbar=no, scrollbars=yes, resizable=yes, left=20, top=20, width=1024', height=768");
[red]//[/red]win.document.getElementById("pvData").innerHTML = tinyMCE.getContent();
[blue]setTimeout("loadContent()",20);[/blue]
return true;
}
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top