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

📄 ajaxedpage.asp

📁 javasrcipt编写的Ajax的类库
💻 ASP
📖 第 1 页 / 共 2 页
字号:
		end if
		writeln("</script>")
	end sub
	
	'******************************************************************************************************************
	'' @SDESCRIPTION:	OBSOLETE! use lib.error() instead.
	'******************************************************************************************************************
	public sub [error](msg)
		lib.error(msg)
	end sub
	
	'******************************************************************************************************************
	'' @SDESCRIPTION:	gets the value from a given form field after postback
	'' @DESCRIPTION:	just an equivalent for request.form.
	'' @PARAM:			name [string]: name of the value you want to get
	'' @RETURN:			[string] value from the request-form-collection.
	'******************************************************************************************************************
	public function RF(name)
		RF = request.form(name)
	end function
	
	'******************************************************************************************************************
	'' @SDESCRIPTION:	gets the value from a given form field and encodes the string into HTML.
	''					useful if you want the value be HTML encoded. e.g. inserting into value fields
	'' @PARAM:			name [string]: name of the value you want to get
	'' @RETURN:			[string] value from the request-form-collection
	'******************************************************************************************************************
	public function RFE(name)
		RFE = str.HTMLEncode(RF(name))
	end function
	
	'******************************************************************************************************************
	'' @SDESCRIPTION:	gets the value of a given form field and trims it automatically.
	'' @PARAM:			name [string]: name of the formfield you want to get
	'' @RETURN:			[string] value from the request-form-collection
	'******************************************************************************************************************
	public function RFT(name)
		RFT = trim(RF(name))
	end function
	
	'******************************************************************************************************************
	'' @SDESCRIPTION:	returns true if a given value exists in the request.form
	'' @PARAM:			name [string]: name of the value you want to get
	'' @RETURN:			[bool] false if there is not value returned. true if yes
	'******************************************************************************************************************
	public function RFHas(name)
		RFHas = (trim(RF(name)) <> "")
	end function
	
	'******************************************************************************************************************
	'' @SDESCRIPTION:	just an equivalent for request.querystring. if empty then returns whole querystring.
	'' @PARAM:			name [string]: name of the value you want to get. leave it empty to get the whole querystring
	'' @RETURN:			[string] value from the request-querystring-collection
	'******************************************************************************************************************
	public function QS(name)
		if name = "" then
			QS = request.querystring
		else
			QS = request.querystring(name)
		end if
	end function
	
	'******************************************************************************************************************
	'' @SDESCRIPTION:	Loads a specified javscript-file
	'' @DESCRIPTION:	it will load the file only if it has not been already loaded on the page before.
	''					so you can load the file and dont have to worry if it will be loaded more than once.
	''					differentiation between the files is the filename (case-sensitive!).
	''					does not work on callback()
	'' @PARAM:			url [string]: url of your javascript-file
	'******************************************************************************************************************
	public sub loadJSFile(url)
		if isCallback() then exit sub
		sourceID = "JS" & url
		if not loadedSources.exists(sourceID) then
			writeln("<script type=""text/javascript"" language=""javascript"" src=""" & url & """></script>")
			loadedSources.add sourceID, empty
		end if
	end sub
	
	'******************************************************************************************************************
	'' @SDESCRIPTION:	Loads a specified stylesheet-file
	'' @DESCRIPTION:	does not work on callback()
	'' @PARAM:			url [string]: url of your stylesheet
	'' @PARAM:			media [string]: what media is this stylesheet for. screen, etc.
	''					leave it blank if its for every media
	'******************************************************************************************************************
	public sub loadCSSFile(url, media)
		if isCallback() then exit sub
		sourceID = "CSS" & url & media
		if not loadedSources.exists(sourceID) then
			writeln("<link rel=""stylesheet"" type=""text/css""" & lib.iif(media <> "", " media=""" & media & """", empty) & " href=""" & url & """ />")
			loadedSources.add sourceID, empty
		end if
	end sub
	
	'******************************************************************************************************************
	'' @DESCRIPTION: 	OBSOLETE! use lib.iif instead
	'******************************************************************************************************************
	public function iif(i, j, k)
    	iif = lib.iif(i, j, k)
	end function
	
	'******************************************************************************************************************
	'' @SDESCRIPTION:	gets the location of the page you are in. virtual, physical, file or the full URL of the page
	'' @PARAM:			format [string]: the format you want the location be returned: PHYSICAL (c:\web\f.asp), VIRTUAL (/web/f.asp),
	''					FULL (http://web/f.asp) or FILE (f.asp). Full takes the protocol into consideration (https or http)
	'' @PARAM:			withQS [bool]: should the querystring be appended or not?
	'' @RETURN:			[string] the location of the executing page in the wanted format
	'******************************************************************************************************************
	public function getLocation(byVal format, withQS)
		format = lCase(format)
		with request
			getLocation = .serverVariables("SCRIPT_NAME")
			select case format
				case "physical"
					getLocation = server.mapPath(getLocation)
				case "virtual"
				case "full"
					protocol = lib.iif(lcase(.serverVariables("HTTPS")) = "off", "http://", "https://")
					getLocation = protocol & .serverVariables("SERVER_NAME") & getLocation
				case else
					parts = split(getLocation, "/")
					getLocation = parts(uBound(parts))
			end select
			if format <> "physical" and withQS and QS("") <> "" then getLocation = getLocation & "?" & QS("")
		end with
	end function
	
	'**********************************************************************************************************
	'' @SDESCRIPTION:	OBSOLETE! use lib.throwError instead
	'**********************************************************************************************************
	public sub throwError(args)
		lib.throwError(args)
	end sub
	
	'******************************************************************************************************************
	'* isCallback 
	'******************************************************************************************************************
	private function isCallback()
		isCallback = RFHas(callbackFlagName)
	end function
	
	'******************************************************************************************************************
	'* setHTTPHeader 
	'******************************************************************************************************************
	private sub setHTTPHeader()
		with response
			'UTF8 is necessary when working with prototype!
			.codePage = 65001
			.charset = "utf-8"
			.expires = 0
			if not isCallback() then .buffer = buffering
			if isCallback() then
				.contentType = "application/json"
			elseif contentType <> "" then
				.contentType = contentType
			end if
		end with
	end sub
	
	'**********************************************************************************************************
	'* loc 
	'**********************************************************************************************************
	private function loc(path)
		loc = componentLocation & path
	end function

end class
%>

⌨️ 快捷键说明

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