How to load a page from file in browser using javascript

Discussion in 'Javascript' started by anonieko@hotmail.com, Feb 25, 2005.

  1. Guest

    > Use x = window.Open(...) x.document.write( yourhtml)
    > How to print from javascript using .print
    > How to use ContentWindow
    >
    > How t use getElementById
    > How to get HTML of document using document.body.innerHTML



    // mail.js
    var viewMode = 1; // WYSIWYG

    function Init()
    {
    iView.document.designMode = 'On';
    }

    function selOn(ctrl)
    {
    ctrl.style.borderColor = '#000000';
    ctrl.style.backgroundColor = '#B5BED6';
    ctrl.style.cursor = 'hand';
    }

    function selOff(ctrl)
    {
    ctrl.style.borderColor = '#D6D3CE';
    ctrl.style.backgroundColor = '#D6D3CE';
    }

    function selDown(ctrl)
    {
    ctrl.style.backgroundColor = '#8492B5';
    }

    function selUp(ctrl)
    {
    ctrl.style.backgroundColor = '#B5BED6';
    }

    function doBold()
    {
    iView.document.execCommand('bold', false, null);
    }

    function doItalic()
    {
    iView.document.execCommand('italic', false, null);
    }

    function doUnderline()
    {
    iView.document.execCommand('underline', false, null);
    }

    function doLeft()
    {
    iView.document.execCommand('justifyleft', false, null);
    }

    function doCenter()
    {
    iView.document.execCommand('justifycenter', false, null);
    }

    function doRight()
    {
    iView.document.execCommand('justifyright', false, null);
    }

    function doOrdList()
    {
    iView.document.execCommand('insertorderedlist', false, null);
    }

    function doBulList()
    {
    iView.document.execCommand('insertunorderedlist', false, null);
    }

    function doForeCol()
    {
    var fCol = prompt('Enter foreground color', '');

    if(fCol != null)
    iView.document.execCommand('forecolor', false, fCol);
    }

    function doBackCol()
    {
    var bCol = prompt('Enter background color', '');

    if(bCol != null)
    iView.document.execCommand('backcolor', false, bCol);
    }

    function doLink()
    {
    iView.document.execCommand('createlink');
    }

    function doImage()
    {
    var imgSrc = prompt('Enter image location', '');

    if(imgSrc != null)
    iView.document.execCommand('insertimage', false, imgSrc);
    }

    function doRule()
    {
    iView.document.execCommand('inserthorizontalrule', false, null);
    }

    function doFont(fName)
    {
    if(fName != '')
    iView.document.execCommand('fontname', false, fName);
    }

    function doSize(fSize)
    {
    if(fSize != '')
    iView.document.execCommand('fontsize', false, fSize);
    }

    function doHead(hType)
    {
    if(hType != '')
    {
    iView.document.execCommand('formatblock', false, hType);
    doFont(selFont.options[selFont.selectedIndex].value);
    }
    }

    function doToggleView()
    {
    if(viewMode == 1)
    {
    iHTML = iView.document.body.innerHTML;
    iView.document.body.innerText = iHTML;

    // Hide all controls
    tblCtrls.style.display = 'none';
    selFont.style.display = 'none';
    selSize.style.display = 'none';
    selHeading.style.display = 'none';
    iView.focus();

    viewMode = 2; // Code
    }
    else
    {
    iText = iView.document.body.innerText;
    iView.document.body.innerHTML = iText;

    // Show all controls
    tblCtrls.style.display = 'inline';
    selFont.style.display = 'inline';
    selSize.style.display = 'inline';
    selHeading.style.display = 'inline';
    iView.focus();

    viewMode = 1; // WYSIWYG
    }
    }

    function Send(form) {
    var iframeID = document.getElementById("iView");
    var middlebody = null;
    if (iframeID==null) {
    alert=("iFrame is NULL");
    } else {
    middlebody = iView.document.body.innerHTML;
    }
    var body = document.getElementById("upperMail").innerHTML + middlebody
    + document.getElementById("lowerMail").innerHTML;

    for ( i=0; i < document.siteManagerForm.elements.length; ++i) {
    if ( document.siteManagerForm.elements.type == "hidden" ) {
    if ( document.siteManagerForm.elements.name == "mailContent"
    ) {
    document.siteManagerForm.elements.value = body;
    break;
    }
    }
    }
    form.submit();
    }

    function Preview(form) {
    var title = "<head><title>Letter Preview</title></head>";
    var closeButton = "<input type=button value=close
    onclick='window.close()'>";
    var line = "<hr border=\"1\" height=\"1px\" color=\"dee1f3\"/>"

    var middlebody = null;

    var iframeID = document.getElementById("iView");
    if (iframeID==null) {
    alert=("Warning: iFrame is NULL");
    } else {
    middlebody = iView.document.body.innerHTML;
    }
    var body = document.getElementById("upperMail").innerHTML + middlebody
    + document.getElementById("lowerMail").innerHTML;
    var header = title+closeButton+line;
    var footer = line+closeButton;
    x=window.open("", "preview", "width=750, height=800, left=0, top=0,
    menubar=no, status=no, location=no, toolbar=no, scrollbars=yes,
    resizable=yes");
    x.document.write(header + body + footer);
    return false;
    }

    function Print() {
    document.getElementById("iView").contentWindow.print();
    }
    , Feb 25, 2005
    #1
    1. Advertising

  2. Guest

    Re: How to load a page from file in browser using javascript

    wrote:
    > > Use x = window.Open(...) x.document.write( yourhtml)
    > > How to print from javascript using .print
    > > How to use ContentWindow
    > >
    > > How t use getElementById
    > > How to get HTML of document using document.body.innerHTML

    >
    >
    > // mail.js
    > var viewMode = 1; // WYSIWYG
    >
    > function Init()
    > {
    > iView.document.designMode = 'On';
    > }
    >
    > function selOn(ctrl)
    > {
    > ctrl.style.borderColor = '#000000';
    > ctrl.style.backgroundColor = '#B5BED6';
    > ctrl.style.cursor = 'hand';
    > }
    >
    > function selOff(ctrl)
    > {
    > ctrl.style.borderColor = '#D6D3CE';
    > ctrl.style.backgroundColor = '#D6D3CE';
    > }
    >
    > function selDown(ctrl)
    > {
    > ctrl.style.backgroundColor = '#8492B5';
    > }
    >
    > function selUp(ctrl)
    > {
    > ctrl.style.backgroundColor = '#B5BED6';
    > }
    >
    > function doBold()
    > {
    > iView.document.execCommand('bold', false, null);
    > }
    >
    > function doItalic()
    > {
    > iView.document.execCommand('italic', false, null);
    > }
    >
    > function doUnderline()
    > {
    > iView.document.execCommand('underline', false, null);
    > }
    >
    > function doLeft()
    > {
    > iView.document.execCommand('justifyleft', false, null);
    > }
    >
    > function doCenter()
    > {
    > iView.document.execCommand('justifycenter', false, null);
    > }
    >
    > function doRight()
    > {
    > iView.document.execCommand('justifyright', false, null);
    > }
    >
    > function doOrdList()
    > {
    > iView.document.execCommand('insertorderedlist', false, null);
    > }
    >
    > function doBulList()
    > {
    > iView.document.execCommand('insertunorderedlist', false, null);
    > }
    >
    > function doForeCol()
    > {
    > var fCol = prompt('Enter foreground color', '');
    >
    > if(fCol != null)
    > iView.document.execCommand('forecolor', false, fCol);
    > }
    >
    > function doBackCol()
    > {
    > var bCol = prompt('Enter background color', '');
    >
    > if(bCol != null)
    > iView.document.execCommand('backcolor', false, bCol);
    > }
    >
    > function doLink()
    > {
    > iView.document.execCommand('createlink');
    > }
    >
    > function doImage()
    > {
    > var imgSrc = prompt('Enter image location', '');
    >
    > if(imgSrc != null)
    > iView.document.execCommand('insertimage', false, imgSrc);
    > }
    >
    > function doRule()
    > {
    > iView.document.execCommand('inserthorizontalrule', false, null);
    > }
    >
    > function doFont(fName)
    > {
    > if(fName != '')
    > iView.document.execCommand('fontname', false, fName);
    > }
    >
    > function doSize(fSize)
    > {
    > if(fSize != '')
    > iView.document.execCommand('fontsize', false, fSize);
    > }
    >
    > function doHead(hType)
    > {
    > if(hType != '')
    > {
    > iView.document.execCommand('formatblock', false, hType);
    > doFont(selFont.options[selFont.selectedIndex].value);
    > }
    > }
    >
    > function doToggleView()
    > {
    > if(viewMode == 1)
    > {
    > iHTML = iView.document.body.innerHTML;
    > iView.document.body.innerText = iHTML;
    >
    > // Hide all controls
    > tblCtrls.style.display = 'none';
    > selFont.style.display = 'none';
    > selSize.style.display = 'none';
    > selHeading.style.display = 'none';
    > iView.focus();
    >
    > viewMode = 2; // Code
    > }
    > else
    > {
    > iText = iView.document.body.innerText;
    > iView.document.body.innerHTML = iText;
    >
    > // Show all controls
    > tblCtrls.style.display = 'inline';
    > selFont.style.display = 'inline';
    > selSize.style.display = 'inline';
    > selHeading.style.display = 'inline';
    > iView.focus();
    >
    > viewMode = 1; // WYSIWYG
    > }
    > }
    >
    > function Send(form) {
    > var iframeID = document.getElementById("iView");
    > var middlebody = null;
    > if (iframeID==null) {
    > alert=("iFrame is NULL");
    > } else {
    > middlebody = iView.document.body.innerHTML;
    > }
    > var body = document.getElementById("upperMail").innerHTML +

    middlebody
    > + document.getElementById("lowerMail").innerHTML;
    >
    > for ( i=0; i < document.siteManagerForm.elements.length; ++i) {
    > if ( document.siteManagerForm.elements.type == "hidden" ) {
    > if ( document.siteManagerForm.elements.name ==

    "mailContent"
    > ) {
    > document.siteManagerForm.elements.value = body;
    > break;
    > }
    > }
    > }
    > form.submit();
    > }
    >
    > function Preview(form) {
    > var title = "<head><title>Letter Preview</title></head>";
    > var closeButton = "<input type=button value=close
    > onclick='window.close()'>";
    > var line = "<hr border=\"1\" height=\"1px\" color=\"dee1f3\"/>"
    >
    > var middlebody = null;
    >
    > var iframeID = document.getElementById("iView");
    > if (iframeID==null) {
    > alert=("Warning: iFrame is NULL");
    > } else {
    > middlebody = iView.document.body.innerHTML;
    > }
    > var body = document.getElementById("upperMail").innerHTML +

    middlebody
    > + document.getElementById("lowerMail").innerHTML;
    > var header = title+closeButton+line;
    > var footer = line+closeButton;
    > x=window.open("", "preview", "width=750, height=800, left=0, top=0,
    > menubar=no, status=no, location=no, toolbar=no, scrollbars=yes,
    > resizable=yes");
    > x.document.write(header + body + footer);
    > return false;
    > }
    >
    > function Print() {
    > document.getElementById("iView").contentWindow.print();
    > }
    , Feb 26, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mad Scientist Jr
    Replies:
    7
    Views:
    1,149
    Emma Gumbdough
    Jun 30, 2004
  2. venky

    Page Load and webcontrol page load

    venky, Jul 6, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    3,083
    venky
    Jul 11, 2005
  3. Jensen bredal
    Replies:
    2
    Views:
    6,151
    Eliyahu Goldin
    Oct 6, 2005
  4. Matcon
    Replies:
    3
    Views:
    21,538
    Matcon
    May 28, 2008
  5. Duke
    Replies:
    1
    Views:
    151
    Tom de Neef
    Apr 18, 2008
Loading...

Share This Page