...

View Full Version : Preview page function



starrwriter
06-24-2004, 01:00 AM
I have written a preview page function for the WYSIWYG editor I'm developing, but it doesn't work and I can't figure out why. I get error message "Access denied" on one line. Here's the script:

function previewPage() {
iView.document.execCommand('SaveAs',null,'popup');
win.document.write('popup'); Error message here: Access denied
win = window.open(", ", 'popup', 'toolbar = yes, menubar = yes, status = yes, scrollbars = yes, resizable = yes');
}

(iView is the name of the iframe where the HTML is written for the page under construction.)

I have a script to preview the outerHTML (body only), but that doesn't include effects from javascript or CSS in the <head> section. I know the page has to be saved before it can be previewed in full, which is why I inserted the execCommand SaveAs line first. But why won't the script write the HTML for the popup page to be opened?

SlySecretSpy
06-24-2004, 01:18 AM
function previewPage() {
iView.document.execCommand('SaveAs',null,'popup');

.....wouldn't you have to define win before you write to it?.....

win.document.write('popup');
win = window.open(", ", 'popup', 'toolbar = yes, menubar = yes, status = yes, scrollbars = yes, resizable = yes');
}

aka

function previewPage() {
iView.document.execCommand('SaveAs',null,'popup');
win = window.open(", ", 'popup', 'toolbar = yes, menubar = yes, status = yes, scrollbars = yes, resizable = yes');
win.document.write('popup');
}

starrwriter
06-24-2004, 04:10 AM
function previewPage() {
iView.document.execCommand('SaveAs',null,'popup');
win = window.open(", ", 'popup', 'toolbar = yes, menubar = yes, status = yes, scrollbars = yes, resizable = yes');
win.document.write('popup');
}

That produces a popup page that only has the word "popup" in it.

win.document.write(iView) produces a page with only "[object]".

glenngv
06-24-2004, 04:59 AM
Like this?

win = window.open('about:blank', 'popup', '...');
win.document.write(iView.document.documentElement.outerHTML);
win.document.close();
win.focus();

starrwriter
06-24-2004, 06:15 AM
Like this?

win = window.open('about:blank', 'popup', '...');
win.document.write(iView.document.documentElement.outerHTML);
win.document.close();
win.focus();

I was sure this wouldn't work because I thought outerHTML only captured the page from <body> to </body> and left out the <head> section. But I was wrong -- works perfectly!

Thanks for your help. I'm still learning and it's a slow process.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum