web页面有时候无法避免使用javascript,但是如果用户浏览器不支持的话,也需要给出友好提示,以下是我作的登录页面在javascript有效和无效两种情况下的处理代码。
<noscript>您的浏览器不支持javascript,请正确设置!</noscript>
<SCRIPT type="text/javascript">
document.write('请输入用户名和密码<br><br>');
</SCRIPT>
<html:form action="/Login" focus="username">
<html:errors/>
<SCRIPT type="text/javascript">
document.writeln('<table border="0" cellpadding="5" cellspacing="5" width="320px">');
document.writeln('<tr>');
document.writeln('<th align="left">ID</th>');
document.writeln('<td align="left"><input type="text" name="username" size="30" maxlength="10"></td>');
document.writeln('<td></td>');
document.writeln('</tr>');
document.writeln('<tr>');
document.writeln('<th align="left">Password</th>');
document.writeln('<td align="left"><input type="password" name="password" size="30" maxlength="18"></td>');
document.writeln('<td></td>');
document.writeln('</tr>');
document.writeln('<tr>');
document.writeln('<td colspan="3" align="right"><input name="login" type="image" src="/imgs/login.gif" alt="Login"></td>');
document.writeln('</tr>');
document.writeln('</table>');
</SCRIPT>
</html:form>
<noscript>您的浏览器不支持javascript,请正确设置!</noscript>
<SCRIPT type="text/javascript">
document.write('请输入用户名和密码<br><br>');
</SCRIPT>
<html:form action="/Login" focus="username">
<html:errors/>
<SCRIPT type="text/javascript">
document.writeln('<table border="0" cellpadding="5" cellspacing="5" width="320px">');
document.writeln('<tr>');
document.writeln('<th align="left">ID</th>');
document.writeln('<td align="left"><input type="text" name="username" size="30" maxlength="10"></td>');
document.writeln('<td></td>');
document.writeln('</tr>');
document.writeln('<tr>');
document.writeln('<th align="left">Password</th>');
document.writeln('<td align="left"><input type="password" name="password" size="30" maxlength="18"></td>');
document.writeln('<td></td>');
document.writeln('</tr>');
document.writeln('<tr>');
document.writeln('<td colspan="3" align="right"><input name="login" type="image" src="/imgs/login.gif" alt="Login"></td>');
document.writeln('</tr>');
document.writeln('</table>');
</SCRIPT>
</html:form>