How to print from javascript using .print
How to use ContentWindow
How t use getElementById
How to get HTML of document using document.body.i nnerHTML
// mail.js
var viewMode = 1; // WYSIWYG
function Init()
{
iView.document. designMode = 'On';
}
function selOn(ctrl)
{
ctrl.style.bord erColor = '#000000';
ctrl.style.back groundColor = '#B5BED6';
ctrl.style.curs or = 'hand';
}
function selOff(ctrl)
{
ctrl.style.bord erColor = '#D6D3CE';
ctrl.style.back groundColor = '#D6D3CE';
}
function selDown(ctrl)
{
ctrl.style.back groundColor = '#8492B5';
}
function selUp(ctrl)
{
ctrl.style.back groundColor = '#B5BED6';
}
function doBold()
{
iView.document. execCommand('bo ld', false, null);
}
function doItalic()
{
iView.document. execCommand('it alic', false, null);
}
function doUnderline()
{
iView.document. execCommand('un derline', false, null);
}
function doLeft()
{
iView.document. execCommand('ju stifyleft', false, null);
}
function doCenter()
{
iView.document. execCommand('ju stifycenter', false, null);
}
function doRight()
{
iView.document. execCommand('ju stifyright', false, null);
}
function doOrdList()
{
iView.document. execCommand('in sertorderedlist ', false, null);
}
function doBulList()
{
iView.document. execCommand('in sertunorderedli st', false, null);
}
function doForeCol()
{
var fCol = prompt('Enter foreground color', '');
if(fCol != null)
iView.document. execCommand('fo recolor', false, fCol);
}
function doBackCol()
{
var bCol = prompt('Enter background color', '');
if(bCol != null)
iView.document. execCommand('ba ckcolor', false, bCol);
}
function doLink()
{
iView.document. execCommand('cr eatelink');
}
function doImage()
{
var imgSrc = prompt('Enter image location', '');
if(imgSrc != null)
iView.document. execCommand('in sertimage', false, imgSrc);
}
function doRule()
{
iView.document. execCommand('in serthorizontalr ule', false, null);
}
function doFont(fName)
{
if(fName != '')
iView.document. execCommand('fo ntname', false, fName);
}
function doSize(fSize)
{
if(fSize != '')
iView.document. execCommand('fo ntsize', false, fSize);
}
function doHead(hType)
{
if(hType != '')
{
iView.document. execCommand('fo rmatblock', false, hType);
doFont(selFont. options[selFont.selecte dIndex].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.d isplay = 'none';
selSize.style.d isplay = 'none';
selHeading.styl e.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.d isplay = 'inline';
selSize.style.d isplay = 'inline';
selHeading.styl e.display = 'inline';
iView.focus();
viewMode = 1; // WYSIWYG
}
}
function Send(form) {
var iframeID = document.getEle mentById("iView ");
var middlebody = null;
if (iframeID==null ) {
alert=("iFrame is NULL");
} else {
middlebody = iView.document. body.innerHTML;
}
var body = document.getEle mentById("upper Mail").innerHTM L + middlebody
+ document.getEle mentById("lower Mail").innerHTM L;
for ( i=0; i < document.siteMa nagerForm.eleme nts.length; ++i) {
if ( document.siteMa nagerForm.eleme nts[i].type == "hidden" ) {
if ( document.siteMa nagerForm.eleme nts[i].name == "mailConten t"
) {
document.siteMa nagerForm.eleme nts[i].value = body;
break;
}
}
}
form.submit();
}
function Preview(form) {
var title = "<head><title>L etter 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.getEle mentById("iView ");
if (iframeID==null ) {
alert=("Warning : iFrame is NULL");
} else {
middlebody = iView.document. body.innerHTML;
}
var body = document.getEle mentById("upper Mail").innerHTM L + middlebody
+ document.getEle mentById("lower Mail").innerHTM L;
var header = title+closeButt on+line;
var footer = line+closeButto n;
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.writ e(header + body + footer);
return false;
}
function Print() {
document.getEle mentById("iView ").contentWindo w.print();
}