我正在致力於現有應用程序的508條款合規性。Ajaxtoolkit的可訪問性問題
現在,當我使用http://achecker.ca/checker/index.php來測試我的頁面爲Section 508時,它顯示「腳本必須有一個noscript節」。爲Ajax生成的腳本。
如何讓Ajax工具包在客戶端生成腳本後添加noscript標籤。
我正在致力於現有應用程序的508條款合規性。Ajaxtoolkit的可訪問性問題
現在,當我使用http://achecker.ca/checker/index.php來測試我的頁面爲Section 508時,它顯示「腳本必須有一個noscript節」。爲Ajax生成的腳本。
如何讓Ajax工具包在客戶端生成腳本後添加noscript標籤。
在Global.asax中我已經加入以下事件和它的工作就像一個魅力
空隙Application_PostReleaseRequestState(對象發件人,EventArgs的)
{
//add no script tag for 508 compatibility
if(Response.ContentType == "text/html")
{
//add no script tag for 508 compatibility
Response.Filter = new NoScriptTagAppendFilter(Response.Filter);
}
}
公共NoScriptTagAppendFilter(流流)
{
outputStream = stream;
}
public override void Write(byte[] buffer, int offset, int count)
{
//base.Write(buffer, offset, count);
string data = UTF8Encoding.UTF8.GetString(buffer);
data = Regex.Replace(data, "</script>", "</script><noscript></noscript>");
outputStream.Write(UTF8Encoding.UTF8.GetBytes(data), offset, UTF8Encoding.UTF8.GetByteCount(data));
data = null;
}
這肯定會幫助未來的某個人想要對由Ajax &測試生成的腳本進行508兼容性測試使用http://achecker.ca/checker/index.php
A noscript
標記用於顯示腳本的替代方法,例如當用戶將其禁用時。所以,如果您有:
<script type="text/javascript">
<!--
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
document.write(month + "/" + day + "/" + year)
//-->
</script>
也就是說,如果你的代碼塊之後或頁共上有一個<noscript>
檢查時看到的。對於較大的AJAX供電應用程序,<noscript>
出現在關閉<body>
之前。確保你對你說/放的東西使用正確的判斷。我見過開發人員:
<script type="text/javascript">
<!--
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
document.write(month + "/" + day + "/" + year)
//-->
</script>
<noscript>
<p>Wow, you suck because you disabled javascript.</p>
</noscript>
請比這更成熟。