Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    May 2004
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Preview page function

    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?

  • #2
    New Coder
    Join Date
    Nov 2003
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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');
    }

  • #3
    New Coder
    Join Date
    May 2004
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by SlySecretSpy
    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]".

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    Like this?

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

  • #5
    New Coder
    Join Date
    May 2004
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by glenngv
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •