發表文章

目前顯示的是 12月, 2011的文章

CFSCRIPT是什麼?

來聊一下什麼是 CFSCRIPT 吧: ColdFusion 使用的基礎語言是 CFML ,原文:ColdFusion Markup Language。 意思是 Coldfusion 標記語言,就跟 HTML 一樣屬於標記式 ( tag ) 的程式語法。 相關的資訊可以在 維基網站 查得到,這裡不再多述。 那麼有了 CFML 後為什麼又需要 CFSCRIPT 了呢?

Coldfusion如何使用編/解碼

以下程式碼可能需要 CF9 以上的版本,目前測試 Railo 3.3 可以正常運作。 傳遞資料的時候有時候須要將資料進行編碼或是解碼, 雖然 javascript 可以完成這樣的工作, 但有時候因為隱匿的關係不希望使用者端解譯其運作原理,所以最好是在 Server 端完成。 Coldfusion 可以處理基本的編解碼有三種形式: Hex: use the characters 0-9 and A-F to represent the hexadecimal value of each byte; for example, 3A. UU: use the UNIX UUencode algorithm to convert the data. Base64: use the Base64 algorithm to convert the data, as specified by IETF RFC 2045, at www.ietf.org/rfc/rfc2045.txt . 比較常見的大多是 Base64吧。 以下是完整的測試網頁:

在CFSCRIPT下使用Cookie

Coldfusion繼續來玩Cookie吧, 注意下面的操作可能需要 CF9 以上的版本, Railo 3.3 以上的版本執行上沒有問題。 繼上一篇 Using cookie in CFML 之後,如果想在 Cfscript 中使用cookie的操作要怎麼辦? 目前尋遍 adobe 官方文件 得到的結果是: Direct assignment of Cookie scope memory-only variables. You cannot use direct assignment to set persistent cookies that are stored on the user's system. 真是沒輒!! 但是還是有辦法操作的,就是利用 cf-tag 與 cfscript 混用: 首先,寫一段處理 cookie 的 Function : <cffunction name="setCookie" access="public" returnType="void" output="false">  <cfargument name="name" type="string" required="true">  <cfargument name="value" type="string" required="false">  <cfargument name="expires" type="any" required="false">  <cfargument name="domain" type="string" required="false">  <cfargument name="httpOnly" type="boolean" required="false&q