21-2 ?用式??用:??顯?ASP 網?

bez`Aڭ̤wgFpϥ JavaScript qΪܪkbΤݶiirPNAQΦP˪覡Aڭ̤]HbAݨϥγqΪܪkӶiUΡC`NHUɮתܡAӻqΪܪkΡC

@밪rs边Nuܡv\AҦpApGڭ̨ϥ Ultraedit ӽs@ asp ɮסAҬݨ쪺epUG

bWz Ultraedit eܤAڭ̤wgiHݥXAServer-side {XwgϥβHܡA Client-side nҤ]wgϥŦܡALrhH¦ܡCHoؤ覡 asp AH@AMAߨ誾D{XIAL׬OnsάOоǡA|eC

ڭ̥iHϥ JScript qΪܪkӹF\AUO@²檺JdҡG

Example]codeDisplay/aspDisplay.asp?url=/jang/books/asp/example/password/auth.asp^G

WzdҪlXpUG

lɡ]codeDisplay/aspDisplay.asp^G]ǦϰUYi^
<%@language=JScript%>
<% title=" ASP e" %>
<!--#include file="../head.inc"-->
<hr>

<%
function fileRead(fileName){
	var fso = new ActiveXObject("Scripting.FileSystemObject");
	var fid = fso.OpenTextFile(realPath, 1);		// }ҰŪɮ
	var fileContents = fid.ReadAll();			// Ūɮת
	fid.Close();
	return(fileContents);
}

url=Request("url")+"";
if (url=="undefined"){
	Response.write("You need to specify the target URL!!!");
	Response.End();
}
realPath=Server.MapPath(url);				// ɮת|
contents = fileRead(realPath);				// Ūɮפe
// Step1, siAƪG
contents=contents.replace(/</g, "&lt;");		// Nu<vNu&lt;vAHקKsiƪ
contents=contents.replace(/>/g, "&gt;");		// Nu>vNu&gt;vAHקKsiƪ
contents=contents.replace(/\n/g, "<br>");		// NCN<br>
contents=contents.replace(/\t/g, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");	 // NwNKӪŮ
// Step 2, N Server-side JScript ܦG
contents=contents.replace(/&lt;%/g, "<font color=red>&lt;%");	// Nu&lt;%vNu<font color=red>&lt;%v
contents=contents.replace(/%&gt;/g, "%&gt;</font>");		// Nu%&gt;vNu%&gt;</font>v
// Step 3, N Client-side JavaScript ܦŦG
contents=contents.replace(/&lt;script&gt;/gi, "<font color=blue>&lt;script&gt;");
contents=contents.replace(/&lt;script language=javascript&gt;/gi, "<font color=blue>&lt;script language=javascript&gt;");
contents=contents.replace(/&lt;\/script&gt;/gi, "&lt;\/script&gt;<\/font>");
Response.write(contents);
%>

<hr>
<!--#include file="../foot.inc"-->

qWzlXAڭ̥iHDAFU\AqιB⦡Ҷi檺NpUG

  1. siAƪG
    • Nu<vNu&lt;vAHקKsiƪ
    • Nu>vNu&gt;vAHקKsiƪ
    • NCNu<br>v
    • NwNKӪŮ
  2. N Server-side JScript ܦG
    • Nu&lt;%vNu<font color=red>&lt;%vA]NONu<%vNu<font color=red><%v
    • Nu%&gt;vNu%&gt;</font>vA]NONu%>vNu%></font>v
  3. N Client-side JavaScript ܦŦG
    • Nu&lt;script&gt;vNu<font color=blue>&lt;script&gt;vA]NONu<script>vNu<font color=blue><script>v
    • Nu&lt;script language=javascript&gt;vNu<font color=blue>&lt;script language=javascript&gt;vA]NONu<script language=javascript>vNu<font color=blue><script language=javascript>v
    • Nu&lt;/script&gt;vNu&lt;/script&gt;</font>vA]NONu</script>vNu</script></font>v
MAoǥuO²檺NApGJ{XAN[JLN\AHϡuܡv\󧹾C
JScript {]pPΡGΩAݪ ASP