📄 rte_javascript.asp
字号:
Response.Write(" editor.focus();")
Else
Response.Write(" editor.contentWindow.focus();")
End If
%>
hideIframes();
}
<%
'*****************************************************
'*** JavaScript for switching to HTML view *****
'*****************************************************
If blnHTMLView Then
%>
//Function to switch to HTML view
function HTMLview(){
var editor = document.getElementById('WebWizRTE');
<%
'If this is IE then use the following
If RTEenabled = "winIE" Then
%>
//WYSIWYG view
if (htmlOn == true){
var html = editor.contentWindow.document.body.innerText;
editor.contentWindow.document.body.innerHTML = html;
document.getElementById('ToolBar1').style.visibility='visible';
document.getElementById('ToolBar2').style.visibility='visible';
htmlOn = false;
//HTML view
}else{
var html = editor.contentWindow.document.body.innerHTML;
editor.contentWindow.document.body.innerText = html;
document.getElementById('ToolBar1').style.visibility='hidden';
document.getElementById('ToolBar2').style.visibility='hidden';
htmlOn = true;
}<%
'Else for Midas
Else
%>
//WYSIWYG view
if (htmlOn == true){
var html = editor.contentWindow.document.body.ownerDocument.createRange();
html.selectNodeContents(editor.contentWindow.document.body);
editor.contentWindow.document.body.innerHTML = html.toString();
document.getElementById('ToolBar1').style.visibility='visible';
document.getElementById('ToolBar2').style.visibility='visible';
htmlOn = false;
//HTML view
}else{
var html = document.createTextNode(editor.contentWindow.document.body.innerHTML);
editor.contentWindow.document.body.innerHTML = '';
editor.contentWindow.document.body.appendChild(html);
document.getElementById('ToolBar1').style.visibility='hidden';
document.getElementById('ToolBar2').style.visibility='hidden';
htmlOn = true;
}
<%
End If
'If Opera change the focus method
If RTEenabled = "opera" Then
Response.Write(" editor.focus();")
Else
Response.Write(" editor.contentWindow.focus()")
End If
%>
}
<%
End If
'***********************************************
'*** JavaScript for print content *****
'***********************************************
If blnPrint Then
%>
//Function to print editor content
function printEditor(){
<%
'If this is Gekco or Opera then print method is different to IE
If RTEenabled = "Gecko" OR RTEenabled = "opera" Then
Response.Write(" document.getElementById('WebWizRTE').contentWindow.print();")
Else
Response.Write(" document.getElementById('WebWizRTE').contentWindow.document.execCommand('Print');")
End If
%>
}
<%
End If
'***********************************************
'*** JavaScript for clear button *****
'***********************************************
'If new doc is enabled then include the following function
If blnNew Then
%>
//Function to clear editor content
function clearWebWizRTE(){
if (window.confirm('<% = strResetWarningEditorConfirm %>')){
document.getElementById('WebWizRTE').contentWindow.document.body.innerHTML='';
<%
'If Opera change the focus method
If RTEenabled = "opera" Then
Response.Write(" document.getElementById('WebWizRTE').focus();")
Else
Response.Write(" document.getElementById('WebWizRTE').contentWindow.focus()")
End If
%>
}
}
<%
End If
'***********************************************
'*** JavaScript for iframes position *****
'***********************************************
%>
//Iframe top offset
function getOffsetTop(elm){
var mOffsetTop = elm.offsetTop;
var mOffsetParent = elm.offsetParent;
while(mOffsetParent){
mOffsetTop += mOffsetParent.offsetTop;
mOffsetParent = mOffsetParent.offsetParent;
}
return mOffsetTop;
}
//Iframe left offset
function getOffsetLeft(elm){
var mOffsetLeft = elm.offsetLeft;
var mOffsetParent = elm.offsetParent;
while(mOffsetParent){
mOffsetLeft += mOffsetParent.offsetLeft;
mOffsetParent = mOffsetParent.offsetParent;
}
return mOffsetLeft;
}
<%
'***********************************************
'*** JavaScript for iframe hidding *****
'***********************************************
Response.Write("//Function to hide iframes" & _
vbCrLf & "function hideIframes(){")
If blnTextColour OR blnTextBackgroundColour OR blnFontStyle OR blnFontType OR blnFontSize Then
'Colour Palette iframe
If blnTextColour OR blnTextBackgroundColour Then
Response.Write(vbCrLf & " if (document.getElementById('colourPalette').style.visibility=='visible'){document.getElementById('colourPalette').style.visibility='hidden';}")
End If
'Format font Select iframe
If blnFontStyle AND strQuickReply = "" Then
Response.Write(vbCrLf & " if (document.getElementById('formatFont').style.visibility=='visible'){document.getElementById('formatFont').style.visibility='hidden';}")
End If
'Font Select iframe
If blnFontType AND strQuickReply = "" Then
Response.Write(vbCrLf & " if (document.getElementById('fontSelect').style.visibility=='visible'){document.getElementById('fontSelect').style.visibility='hidden';}")
End If
'Font Size iframe
If blnFontSize AND strQuickReply = "" Then
Response.Write(vbCrLf & " if (document.getElementById('textSize').style.visibility=='visible'){document.getElementById('textSize').style.visibility='hidden';}")
End If
End If
Response.Write(vbCrLf & "}")
'***********************************************
'*** JavaScript for spell check detection *****
'***********************************************
'If spell checking is enabled load the following function
If blnSpellCheck Then
%>
//Function to perform spell check
function checkspell(){<%
'If IE
If RTEenabled = "winIE" Then
%>
try{
var tmpis = new ActiveXObject('ieSpell.ieSpellExtension');
tmpis.CheckAllLinkedDocuments(document);
}
catch(exception){
if(exception.number==-2146827859){
if (confirm('<% = strTxtIeSpellNotDetected %>')){
window.open('http://www.iespell.com/download.php','DownLoad', '');
}
}
else
alert('Error Loading ieSpell: Exception ' + exception.number);
}<%
'Else if this is Gecko browser load different JS
ElseIf RTEenabled = "Gecko" Then
%>
if (confirm('<% = strTxtSpellBoundNotDetected %>')){
window.open('http://spellbound.sourceforge.net/install','DownLoad', '');
}<%
End If
%>
}<%
End If
'***********************************************
'*** Editor Keybord/Mouse Events *****
'***********************************************
%>
//Run Editor Events
function editorEvents(evt){
var keyCode = evt.keyCode ? evt.keyCode : evt.charCode;
var keyCodeChar = String.fromCharCode(keyCode).toLowerCase();
<%
'Put in some keybord shortcuts Gecko doesn't have when in RTE mode (IE already has these built in)
If RTEenabled = "Gecko" Then
%>
//Keyboard shortcuts
if (evt.type=='keypress' && evt.ctrlKey){
var kbShortcut;
switch (keyCodeChar){
case 'b': kbShortcut = 'bold'; break;
case 'i': kbShortcut = 'italic'; break;
case 'u': kbShortcut = 'underline'; break;
case 's': kbShortcut = 'strikethrough'; break;
case 'i': kbShortcut = 'italic'; break;
}
if (kbShortcut){
FormatText(kbShortcut, '');
evt.preventDefault();
evt.stopPropagation();
}
}
<%
End If
'Prevent double line spacing in IE (IE SUCKS!!!)
'If this is IE then detect if ENTER key is prssed then replace <p> with <div>
'I would replace <p> with <br>, but this then courses problems within tables, ordered lists, and
'other elements so <div> is used as it creates the same one line effect but without the problems
If RTEenabled = "winIE" AND blnNoIEdblLine Then
%>
//run if enter key is pressed
if (evt.type=='keypress' && keyCode==13){
var editor = document.getElementById('WebWizRTE');
var selectedRange = editor.contentWindow.document.selection.createRange();
var parentElement = selectedRange.parentElement();
var tagName = parentElement.tagName;
while((/^(a|abbr|acronym|b|bdo|big|cite|code|dfn|em|font|i|kbd|label|q|s|samp|select|small|span|strike|strong|sub|sup|textarea|tt|u|var)$/i.test(tagName)) && (tagName!='HTML')){
parentElement = parentElement.parentElement;
tagName = parentElement.tagName;
}
//Insert <div> instead of <p>
if (parentElement.tagName == 'P'||parentElement.tagName=='BODY'||parentElement.tagName=='HTML'||parentElement.tagName=='TD'||parentElement.tagName=='THEAD'||parentElement.tagName=='TFOOT'){
selectedRange.pasteHTML('<div>');
selectedRange.select();
return false;
}
}<%
End If
%>
hideIframes();
return true;
}
<%
'If emoticons are enabled
If blnEmoticons Then
Response.Write(vbCrLf & "//Function to add emoticon")
Response.Write(vbCrLf & "function AddEmoticon(iconItem){")
Response.Write(vbCrLf & vbCrLf & " editor = document.getElementById('WebWizRTE');")
'Tell that we are an image
Response.Write(vbCrLf & vbCrLf & " img = editor.contentWindow.document.createElement('img');")
'Set image attributes
If blnUseFullURLpath = true Then
Response.Write(vbCrLf & vbCrLf & " img.setAttribute('src', '" & strFullURLpathToRTEfiles & "' + iconItem.id);")
Else
Response.Write(vbCrLf & vbCrLf & " img.setAttribute('src', iconItem.id);")
End If
Response.Write(vbCrLf & " img.setAttribute('border', '0');")
Response.Write(vbCrLf & " img.setAttribute('alt', iconItem.title);")
Response.Write(vbCrLf & " img.setAttribute('align', 'absmiddle');")
'If this is Mozilla or Opera then we need to call insertElementPosition to find where to place the image
If RTEenabled = "Gecko" OR RTEenabled = "opera" Then
Response.Write(vbCrLf & vbCrLf & " try{" & _
vbCrLf & " insertElementPosition(editor.contentWindow, img);" & _
vbCrLf & " }catch(exception){" & _
vbCrLf & " alert('" & strTxtErrorInsertingObject & "');" & _
vbCrLf & " editor.contentWindow.focus();" & _
vbCrLf & " }")
'Else this is IE so placing the image is simpler
Else
Response.Write(vbCrLf & vbCrLf & " try{" & _
vbCrLf & " editor.contentWindow.focus();" & _
vbCrLf & " editor.contentWindow.document.selection.createRange().pasteHTML(img.outerHTML);" & _
vbCrLf & " }catch(exception){" & _
vbCrLf & " alert('" & strTxtErrorInsertingObject & "');" & _
vbCrLf & " editor.contentWindow.focus();" & _
vbCrLf & " }")
End If
'set focus
'If Opera change the focus method
If RTEenabled = "opera" Then
Response.Write(vbCrLf & " editor.focus();")
Else
Response.Write(vbCrLf & " editor.contentWindow.focus();")
End If
Response.Write(vbCrLf & "}")
End If
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -