How to load a page from file in browser using javascript

A

anonieko

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();
}
 
P

pinckyg

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();
}
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top