⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rte_javascript.asp

📁 简单的asp论坛源码系统,很适用于初学者!界面简洁,功能齐全
💻 ASP
📖 第 1 页 / 共 2 页
字号:
<% @ Language=VBScript %>
<% Option Explicit %>
<!--#include file="common.asp" -->
<!--#include file="RTE_configuration/RTE_setup.asp" -->
<%
'****************************************************************************************
'**  Copyright Notice    
'**
'**  Web Wiz Rich Text Editor(TM)
'**  http://www.richtexteditor.org
'**                                               
'**  Copyright (C)2001-2008 Web Wiz(TM). All Rights Reserved.  
'**  
'**  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS UNDER LICENSE FROM 'WEB WIZ'.
'**  
'**  IF YOU DO NOT AGREE TO THE LICENSE AGREEMENT THEN 'WEB WIZ' IS UNWILLING TO LICENSE 
'**  THE SOFTWARE TO YOU, AND YOU SHOULD DESTROY ALL COPIES YOU HOLD OF 'WEB WIZ' SOFTWARE
'**  AND DERIVATIVE WORKS IMMEDIATELY.
'**  
'**  If you have not received a copy of the license with this work then a copy of the latest
'**  license contract can be found at:-
'**
'**  http://www.webwizguide.com/license
'**
'**  For more information about this software and for licensing information please contact
'**  'Web Wiz' at the address and website below:-
'**
'**  Web Wiz, Unit 10E, Dawkins Road Industrial Estate, Poole, Dorset, BH15 4JD, England
'**  http://www.webwizguide.com
'**
'**  Removal or modification of this copyright notice will violate the license contract.
'**
'****************************************************************************************



'*************************** SOFTWARE AND CODE MODIFICATIONS **************************** 
'**
'** MODIFICATION OF THE FREE EDITIONS OF THIS SOFTWARE IS A VIOLATION OF THE LICENSE  
'** AGREEMENT AND IS STRICTLY PROHIBITED
'**
'** If you wish to modify any part of this software a license must be purchased
'**
'****************************************************************************************




'Reset Server Objects
Call closeDatabase()

Response.AddHeader "pragma","cache"
Response.AddHeader "cache-control","public"
Response.CacheControl = "Public"

Dim strTextAreaName
Dim strQuickReply

strTextAreaName = removeAllTags(Request.QueryString("textArea"))
strQuickReply = removeAllTags(Request.QueryString("QR"))


'***** START WARNING - REMOVAL OR MODIFICATION OF THIS CODE WILL VIOLATE THE LICENSE AGREEMENT ******
Response.Write(vbCrLf & "<!--//" & _
vbCrLf & "/* *******************************************************" & _
vbCrLf & "Software: Web Wiz Rich Text Editor(TM) ver. " & strRTEversion & "" & _
vbCrLf & "Info: http://www.richtexteditor.org" & _
vbCrLf & "Copyright: (C)2001-2008 Web Wiz(TM). All rights reserved" & _
vbCrLf & "******************************************************* */" & _
vbCrLf & "//-->")
'***** END WARNING - REMOVAL OR MODIFICATION OF THIS CODE WILL VIOLATE THE LICENSE AGREEMENT ******
%>

var colour;
var htmlOn;
var textAreaName = '<% = strTextAreaName %>';

<%



'***********************************************
'***   JavaScript initialising RTE editor  *****
'***********************************************
%>
//initialise RTE editor
function initialiseWebWizRTE(){

	var textArea = document.getElementById(textAreaName);
	var editor = document.getElementById('WebWizRTE').contentWindow.document;

	function initIframe(){
<%

'IE uses contentEditable instead of designMode to prevent runtime errors in IE6.0.26 to IE6.0.28
'IE uses proprietary attachEvent instead of following the W3C Events module and using addEventListener
'IE SUCKS!!
If RTEenabled = "winIE" Then

%>		
		editor.attachEvent('onkeypress', editorEvents);
		editor.attachEvent('onmousedown', editorEvents);
		document.attachEvent('onmousedown', hideIframes);
		editor.body.contentEditable = true;
<%

'Gekco needs designMode enabled AFTER we listen for events using addEventListener
Else
%>		editor.addEventListener('keypress', editorEvents, true);
		editor.addEventListener('mousedown', editorEvents, true);
		document.addEventListener('mousedown', hideIframes, true);
		editor.designMode = 'on';
<%
End If

%>	}
	setTimeout(initIframe, 300);
	
	//resetting the form
	textArea.form.onreset = function(){
		if (window.confirm('<% = strResetWarningFormConfirm %>')){
	 		editor.body.innerHTML = '';
	 		return true;
	 	}
	return false;
	}
}
<%






'**********************************************
'***   JavaScript create RTE toolbar	  *****
'**********************************************
%>
//Create RTE toolbar
function WebWizRTEtoolbar(formName){
<%
	'Open Iframes

	'Colour Palette iframe
	If blnTextColour OR blnTextBackgroundColour Then
		Response.Write(vbCrLf & "	document.writeln('<iframe width=""260"" height=""165"" id=""colourPalette"" src=""includes/RTE_iframe_colour_palette.asp"" style=""visibility:hidden; position: absolute; left: 0px; top: 0px;"" frameborder=""0"" scrolling=""no""></iframe>');")
	End If

	'Format font Select iframe
	If blnFontStyle AND strQuickReply = "" Then
		Response.Write(vbCrLf & "	document.writeln('<iframe width=""240"" height=""250"" id=""formatFont"" src=""includes/RTE_iframe_select_format.asp"" style=""visibility:hidden; position: absolute; left: 0px; top: 0px; border: 1px solid #000000;"" frameborder=""0"" scrolling=""no""></iframe>');")
	End If

	'Font Select iframe
	If blnFontType  AND strQuickReply = "" Then
		Response.Write(vbCrLf & "	document.writeln('<iframe width=""130"" height=""140"" id=""fontSelect"" src=""includes/RTE_iframe_select_font.asp"" style=""visibility:hidden; position: absolute; left: 0px; top: 0px; border: 1px solid #000000;"" frameborder=""0"" scrolling=""no""></iframe>');")
	End If

	'Font Size iframe
	If blnFontSize  AND strQuickReply = "" Then
		Response.Write(vbCrLf & "	document.writeln('<iframe width=""66"" height=""235"" id=""textSize"" src=""includes/RTE_iframe_select_size.asp"" style=""visibility:hidden; position: absolute; left: 0px; top: 0px; border: 1px solid #000000;"" frameborder=""0"" scrolling=""no""></iframe>');")
	End If

%>
	document.writeln('<table id="toolbar" width="600" border="0" cellspacing="0" cellpadding="1" class="RTEtoolbar">');
	document.writeln(' <tr>');
	document.writeln('  <td>');<%

'If quick reply load a different toolbar
If strQuickReply = "true" Then
	%><!--#include file="includes/RTE_quick_reply_toolbar_inc.asp" --><%

'If not quick reply, load standard toolbar
Else
	%><!--#include file="includes/RTE_toolbar_inc.asp" --><%
End If
%>
	document.writeln('  </td>');
	document.writeln(' </tr>');
	document.writeln('</table>');
}
<%







'***********************************************
'*** JavaScript for main editor buttons	   *****
'***********************************************
%>
//Function to format text in the text box
function FormatText(command, option){<%


'If this is the Gecko engine then uncomment the following line if you don't wish to use CSS
If RTEenabled = "Gecko" AND blnUseCSS = false Then Response.Write("	document.getElementById('WebWizRTE').contentWindow.document.execCommand(""useCSS"", false, option);")

%>

	var editor = document.getElementById('WebWizRTE');

	//Show iframes
	if ((command == 'forecolor') || (command == 'backcolor') || (command == 'hilitecolor') || (command == 'fontname') || (command == 'formatblock') || (command == 'fontsize')){
		parent.command = command;
		buttonElement = document.getElementById(command);
		switch (command){
			case 'fontname': iframeWin = 'fontSelect'; break;
			case 'formatblock': iframeWin = 'formatFont'; break;
			case 'fontsize': iframeWin = 'textSize'; break;
			default: iframeWin = 'colourPalette';
		}
<%

	'If Opera change the focus method
	If RTEenabled = "opera" Then
		
		Response.Write("		editor.focus();")
	Else
		Response.Write("		editor.contentWindow.focus()")
	End If

%>
		document.getElementById(iframeWin).style.left = getOffsetLeft(buttonElement) + 'px';
		document.getElementById(iframeWin).style.top = (getOffsetTop(buttonElement) + buttonElement.offsetHeight) + 'px';

		if (document.getElementById(iframeWin).style.visibility=='visible'){
			hideIframes();
		}else{
			hideIframes();
			document.getElementById(iframeWin).style.visibility='visible';
		}

		var selectedRange = editor.contentWindow.document.selection;
		if (selectedRange != null){
			range = selectedRange.createRange();
		}
	}<%



'If this is the Gecko or Opera then check the users preferences are set to cut, copy, or paste
If RTEenabled = "Gecko" OR RTEenabled = "opera" Then

%>
	//Cut, copy, paste for Gecko
	else if ((command == 'cut') || (command == 'copy') || (command == 'paste')){
		try{
<%

	'If Opera change the focus method
	If RTEenabled = "opera" Then
		
		Response.Write("	  		editor.focus();")
	Else
		Response.Write("	  		editor.contentWindow.focus()")
	End If

%>
	  		editor.contentWindow.document.execCommand(command, false, option);
		}catch(exception){
			switch(command){
				case 'cut': keyboard = 'x'; break;
				case 'copy': keyboard = 'c'; break;
				case 'paste': keyboard = 'v'; break;
			}
			alert('<% = strTxtYourBrowserSettingsDoNotPermit %> \'' + command + '\' <% = strTxtPleaseUseKeybordsShortcut %> \(<% = strTxtWindowsUsers %> Ctrl + ' + keyboard + ', <% = strTxtMacUsers %> Apple + ' + keyboard + '\)')
		}

	}<%
End If



'If the advanced hyperlink is not enabled then display a basic hyperlink function
If blnAdvAdddHyperlink = false Then

%>
	else if (command == 'createLink'){

<%

	'Mozilla and Opera use different methods than IE to get the selected text
	If RTEenabled = "Gecko" OR RTEenabled = "opera" Then
		Response.Write("		var selectedRange = editor.contentWindow.window.getSelection().toString();")
	Else
		Response.Write("		var selectedRange = editor.contentWindow.document.selection.createRange().text; ")
	End If
%>
		if (selectedRange != null && selectedRange != ''){
			//place http infront if not already in selected range
			if (selectedRange.substring(0,4) != 'http'){
				selectedRange = 'http://' + selectedRange
			}

			insertLink = prompt('<% = strTxtEnterHeperlinkURL %>', selectedRange);

			if ((insertLink != null) && (insertLink != '')){
<%

	'If Opera change the focus method
	If RTEenabled = "opera" Then
		
		Response.Write("				editor.focus();")
	Else
		Response.Write("				editor.contentWindow.focus()")
	End If

%>
				editor.contentWindow.document.execCommand('CreateLink', false, insertLink);
			}
		}else{
			alert('<% = strTxtSelectTextToTurnIntoHyperlink %>')
		}
	}<%

End If


'Else none of the other command need extra code so run the command as a bsic execCommand in the editor
%>
	else{
	  	editor.contentWindow.focus();
	  	editor.contentWindow.document.execCommand(command, false, option);
	}
<%

	'If Opera change the focus method
	If RTEenabled = "opera" Then
		
		Response.Write("	  	editor.focus();")
	Else
		Response.Write("	  	editor.contentWindow.focus()")
	End If

%>
}
<%

'***********************************************************************************






'************************************************************************
'*** 	JavaScript for initialise commands (iframe colours etc.)    *****
'************************************************************************
%>
//Function to initialise commands
function initialiseCommand(selection){
	var editor = document.getElementById('WebWizRTE')
<%
'If this is IE then use the following
If RTEenabled = "winIE" Then

	%>
	//retrieve selected range
	var selectedRange = editor.contentWindow.document.selection;
	if (selectedRange!=null){
		selectedRange = selectedRange.createRange();
		selectedRange = range;
		selectedRange.select();
	}<%
End If
%>
	editor.contentWindow.document.execCommand(parent.command, false, selection);
<%

'If Opera change the focus method
If RTEenabled = "opera" Then
	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -