Angelos wrote:
I have a page with a form and a text area. In the textarea I write html
code or any text.
Then I hit a button and I open a new window which is a template of a
page and I want to put the content of the textarea from the previous
page inside a content div.
This is the code of the source page:
/********************STARTOF CODE *********************/
<script type="text/JavaScript">
<!--
//dont need to restore borders in change_mode - works faster
function get_content(editor) {
if (!editor)
return '';
var text_area_content;
eval('var text_area = document.getElementById(editor);');
text_area_content = text_area.value;
return text_area_content;
}
function open_window() {
content = get_content('Contentbody');
pre_window = window.open('test_preview.php', 'PREVIEW');
}
//-->
First off, you don't need the <-- and //--> - take them out.
Now, as to the specific problem you're having:
You can address the new window as a variable - so where you have
pre_window = window.open('test_preview.php', 'PREVIEW');
you can now address that window as pre_window. For example:
pre_window.document.write(content);
There are, I think, better ways to handle writing the content (using
DOM), but that should at least get you a start.