|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
Images
IntroductionWell, this is my sixth article. Here, I have tried a fully JavaScript enabled editor. Here I have updated it with more features. CodeIn the article, I am giving sample code. The full code is available in the zip file. This is the updated version. I have included features like inserting images, flashes, templates, media files, special characters and saving templates. I have also included features of inserting HTML controls like button, text box, checkbox, radiobutton, submit button, reset button, select type listbox and dropdownlist, etc. You can also insert date and time in any format. Setting Colorfunction setColor(colorTo,x,y)
{
editFrame.focus();
editFrame.document.execCommand(colorTo,true, colorArray[x][y]);
popDivId.style.display = "none";
}
Setting Fontfunction setFont(fontName)
{
editFrame.focus();
editFrame.document.execCommand("FontName", false, fontName);
popDivId.style.display = "none";
}
Setting Font Sizefunction setFontSize(fontSize)
{
editFrame.focus();
editFrame.document.execCommand("FontSize", false, fontSize);
popDivId.style.display = "none";
}
Setting General Actionfunction doAction(action)
{
editFrame.focus();
if(action == "ClearAll")
{
editFrame.document.execCommand("SelectAll",true);
action = "Delete";
}
editFrame.document.execCommand(action,true);
}
Showing Dialog Boxesfunction showDialog(link,w, h)//380, 125
{
if(link == "li")
link = "InsertLinks.htm";
else if(link == "sc")
link = "SpecialChars.htm";
var returnedTxt= showModalDialog(link,"", "dialogWidth:"+
w +"px; dialogHeight:"+ h +"px; status:no; center:yes");
editFrame.focus();
if(returnedTxt)
{
var theRange = editFrame.document.selection.createRange();
theRange.pasteHTML(returnedTxt);
}
}
Showing Popup Windowsvar cWnd;
function showInsertPopup(opt, w, h) // w=350, h=340
{
var srcfile = "imgWindow.aspx";
if(opt == "im")
srcfile = "imgWindow.aspx";
else if(opt == "fl")
srcfile = "flashWindow.aspx";
else if(opt == "me")
srcfile = "mediaWindow.aspx";
else if(opt == "tm")
srcfile = "templateWindow.aspx";
else if(opt == "st")
srcfile = "saveWindow.aspx";
else if(opt == "tb")
srcfile = "InsertTable.htm";
var left = (window.screen.width - parseInt(w))/2;
var top = (window.screen.height - parseInt(h))/2;
if(cWnd)
cWnd.close();
cWnd = window.open(srcfile,"", "width="+ w +",height="+
h +",location=no, status=no, top="+ top +", left="+ left);
}
Setting HTML Actionfunction doHtmlAction(atype)
{
editFrame.focus();
var selectedRegion = editFrame.document.selection.createRange();
if(atype == "lower")
selectedRegion.text = selectedRegion.text.toLowerCase();
else if(atype == "upper")
selectedRegion.text = selectedRegion.text.toUpperCase();
}
HistoryVersion 1.0
Version 2.0
Version 3.0
Points of Interest
ConclusionThank you. I expect feedback from you, and you expect more from me.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||