Jump to content

script doesn't work in another browser....!


fdark
 Share

Recommended Posts

hello... script doesn't work.. it does work in IE but not in another browser like mozilla,opera & safari? what should I do?....I have changed innerText in moziila to contentText...but many error still appear when I using firebug........like searchElement and document.designMode=docmode......thanks

<!--//PageCreator - WYSIWYG (What you see is what you get) HTML Editor//Language: JavaScript//Runs in Internet Explorer browser version 5.5 or greater//Current HTML of pagevar html="";//View of the page, Normal (Design), HTML, Previewvar currentview=0;//Hold window objects for the color, table and properties dialogsvar table_dialog, color_dialog, properties_dialog;//Current color action, ForeColor, or BackColor,//used for communication between PageCreate window and Color dialog windowvar pp;//Is used to disable use of design tools in HTML or Preview modevar enabletoolbar=false;//Variable counter used to index the search in the documentvar n=0;function InitEditor(){//Init editor in design mode,maineditor.document.designMode=docmode;//Write a blank pageWriteDefaultPage();//Disable context menumaineditor.document.oncontextmenu=new Function("return false;");//Set focus to the editormaineditor.focus();}function EditorView(view){//Changes editor view to Normal, HTML, and Previewif(currentview==1){//If the last view was HTML then get the HTML edited by user in HTML modehtml=maineditor.document.body.innerText;}//If the last mode was Normal then get the whole HTML content of the pageelse html=maineditor.document.all.tags("HTML")[0].outerHTML;if(view==0){//Normal ModeEnableToolbar(true);maineditor.location="about:blank";maineditor.document.designMode=docmode;maineditor.document.open("text/html");maineditor.document.write(html);maineditor.document.close();maineditor.document.oncontextmenu=new Function("return false;");maineditor.focus();}if(view==1){//HTML ModeEnableToolbar(false);maineditor.location="about:blank";maineditor.document.designMode=docmode;WriteDefaultPage();HTMLView();maineditor.document.oncontextmenu=new Function("return false;");}if(view==2){//Preview ModeEnableToolbar(false);maineditor.location="about:blank";//Disable page editingmaineditor.document.designMode="Inherit";//Write the HTML of the pagemaineditor.document.open("text/html");maineditor.document.write(html);maineditor.document.close();//Enable context menumaineditor.document.oncontextmenu=new Function("return true;");}//Set current viewcurrentview=view;}function EnableToolbar(enable){//Enable or disable toolbarenabletoolbar=enable;}function OpenFile(){if(window.confirm("Do you want to save changes in the current document?")){//Show Save As Dialogmaineditor.document.execCommand("SaveAs");}fileopen_dialog.style.visibility="visible";}function OpenSelectedFile(){//Check if the file is an HTML pageif(document.fileselect.thefile.value.indexOf(".htm")==-1){window.alert("The selected file is not an HTML page, please select a valid HTML file");return;}//Hide the open file dialogfileopen_dialog.style.visibility="hidden";//Create the FSO objectvar fso=new ActiveXObject("Scripting.FileSystemObject");//Open the selected filevar f=fso.OpenTextFile(document.fileselect.thefile.value);//Get the content of the filevar thehtml=f.ReadAll();//Close the filef.close();//Write a blank pagemaineditor.window.location="about:blank";//Write the HTML contentmaineditor.document.open("text/html");maineditor.document.write(thehtml);maineditor.document.close();//Set focus to editormaineditor.focus();}function WriteDefaultPage(){//Writes a blank HTML page in the editorvar pagehtml="<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; " +"charset=windows-1252\">\n<meta name=\"GENERATOR\" content=\"PageCreate\">\n" +"<title>New Page</title>\n</head>\n<body>\n</body>\n</html>";maineditor.document.open("text/html");maineditor.document.write(pagehtml);maineditor.document.close();}function NewPage(){if(window.confirm("Do you want to save changes in the current document?")){//Show Save As Dialogmaineditor.document.execCommand("SaveAs");}//Write a blank pagemaineditor.window.location="about:blank";WriteDefaultPage();//Set focus to editormaineditor.focus();}function HTMLView(){//Switch to HTML viewmaineditor.document.body.innerHTML="";maineditor.document.body.innerText=html;}function TableOn(table, on){//Highlights the table on which the mouse is overif(on) table.style.backgroundColor="#95AFFF";else table.style.backgroundColor="#82DF82";}function ToolbarOn(toolon){//Highlights on or off the current toolbar//Get the toolbar button on which the mouse is overvar tool=event.srcElement;//Change background colorif(toolon){tool.style.backgroundColor="#B4A0FE";tool.style.borderColor="#000000";}else{tool.style.backgroundColor="#D1D1D1";tool.style.borderColor="#D1D1D1";} }function FindInPage(showdialog){//Shows the Find and Replace Dialogvar display="visible";if(showdialog==false) display="hidden";find_dialog.style.visibility=display;if(showdialog!=false) document.find.findwhat.focus();}function FindIt(str, replacestr, newstr){//This functions searchs for a string in the document//and if specified then replaces it with a new stringif(str==""){//If no string to search enteredalert("Enter a string to search");document.find.findwhat.focus();return;}//Creates a range in the documenttxt = maineditor.document.body.createTextRange();//Loop to find the string in the documentfor (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {txt.moveStart("character", 1);txt.moveEnd("textedit");}if(found) {//If founded select it and scroll into viewtxt.moveStart("character", -1);txt.findText(str);//If replace is specified then replace the match with the new stringif(replacestr) txt.text=newstr;txt.select();txt.scrollIntoView();n++;}else {if (n > 0) {window.alert("There are no more matches");n=0;}// Not found anywhere, give message.elsewindow.alert("\"" + str + "\" was not founded in document");} } function InsertHTML(newhtml){//Inserts HTML in the selection of the documentmaineditor.focus();var selpoint=maineditor.document.selection.createRange();selpoint.pasteHTML(newhtml);}function GetSelectedText(){//Get the selection of the documentmaineditor.focus();var selpoint=maineditor.document.selection.createRange();var seltext=selpoint.text;return seltext;}function InsertNewImage(){if(enabletoolbar==false) return;maineditor.focus();//Open Insert Image Dialogmaineditor.document.execCommand("insertimage", true, null);}function InsertForm(){//Creates a new formvar formmethod=window.prompt("Choose form method: GET | POST", "POST");var formaction=window.prompt("Choose form action:", "http://");InsertHTML("<div style=\"background-Color:#C0C0C0\"><form method=\"" + formmethod + "\" action=\"" + formaction + "\">\n<p> </p></form></div>");}function InsertFormControl(control){maineditor.focus();//Inserts a form controlmaineditor.document.execCommand(control, true, null);}function CreateNewLink(){//Inserts a link in the selected textif(enabletoolbar==false) return;var linktext=GetSelectedText();if(linktext=="") return;var url=window.prompt("Enter a URL for the new link:", "http://");if(url!=null){InsertHTML("<a href=\"" + url + "\">" + linktext + "</a>");}maineditor.focus();}function InsertTable(){//Open Table Dialogtable_dialog=window.open("table.htm", "newtable", "top=100,left=100,height=300,width=400,scrollbars=no");}function CreateTable(tr, tc, ta, tb, tp, ts, tw, tt){//Creates a new tablevar tablewidth="";if(tw!=""){tablewidth=" width=\"" + tw + tt + "\"";}var thtml="<table border=\"" + tb + "\" cellpadding=\"" + tp + "\" cellspacing=\"" + ts + "\"" + tablewidth + ">";tr=parseInt(tr);tc=parseInt(tc);for(r=0;r<tr;r++){thtml+="<tr>";for(c=0;c<tc;c++){thtml+="<td></td>";}thtml+="</tr>";}thtml+="</table>";InsertHTML(thtml);table_dialog.close();}function EditPage(){properties_dialog=window.open("properties.htm", "editpage", "top=100,left=100,height=275,width=387,scrollbars=no");}function EditPageProperties(pt, pfc, pbgc, pbgi, usewatermark, pbgs){maineditor.document.title=pt;maineditor.document.body.text=pfc;maineditor.document.body.bgColor=pbgc;maineditor.document.body.background=pbgi;if(usewatermark) maineditor.document.body.bgProperties="fixed";else maineditor.document.body.bgProperties="";if(pbgs!=""){var pagehtml=maineditor.document.all.tags("HTML")[0].outerHTML;var bodytag= pagehtml.toLowerCase().indexOf("<body");if(bodytag==-1) return;var beforebodytag=  pagehtml.substring(0, bodytag);var afterbodytag=  pagehtml.substring(bodytag,  pagehtml.length);var pagehtml=beforebodytag + "<bgsound src=\"" + pbgs + "\">" + afterbodytag;maineditor.document.open("text/html");maineditor.document.write(pagehtml);maineditor.document.close();}properties_dialog.close();maineditor.focus();}function ChangeForeColor(){//Show the Color dialog to edit Fore Color of text selectedif(GetSelectedText()!=""){pp="EditForeColor";color_dialog=window.open("color.htm", "colorpicker", "top=100,left=100,height=270,width=500,scrollbars=no");} }function EditForeColor(thecolor){maineditor.focus();//Change fore color of text selectedmaineditor.document.execCommand("forecolor", false, thecolor);//Close Color Dialogcolor_dialog.close();}function ChangeBackColor(){//Show the Color dialog to edit Back Color of text selectedif(GetSelectedText()!=""){pp="EditBackColor";color_dialog=window.open("color.htm?p=EditBackColor", "colorpicker", "top=100,left=100,height=270,width=500,scrollbars=no");} }function EditBackColor(thecolor){maineditor.focus();//Change back color of text selectedmaineditor.document.execCommand("backcolor", false, thecolor);//Close Color Dialogcolor_dialog.close();}function ChangeFont(font){//Changes the font of the selected textmaineditor.focus();maineditor.document.execCommand("fontname", false, font);}function ChangeFontSize(size){//Changes the font size of the selected textmaineditor.focus();maineditor.document.execCommand("fontsize", false, size);}function DesignTools(tool){//Activates design toolif(enabletoolbar==false){window.alert("You must switch into normal view to do this");return;}maineditor.focus();maineditor.document.execCommand(tool, true, null);}//-->

Link to comment
Share on other sites

If you want a WYSIWYG, try this: http://tinymce.moxiecode.com/If you want to save files to your client's hard drive, IE is your only choice.
hello...thanks for advice...but there is something I want to learn in this old script... I have another script that related to this script...any suggestion where I can find tutorial about alternative javascript function between IE and mozilla?
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...