導航:首頁 > 編程語言 > jsp下alert

jsp下alert

發布時間:2023-07-30 06:48:41

1. jsp里alert寫法

首先你的襲代碼有錯:br;1.;language屬性名拼寫錯誤,不過這個在IE裡面應該不會引起問題。br;2.;alert(request.getAttribute(err));;這一句會引起javascript異常,至少應該寫成這樣:alert('%=request.getAttribute(err)%;');。br;br;另外,你這段代碼寫在login.jsp的什麼位置?br;是在head;/head;中,還是在body;/body;中?br;如果寫在head;/head;中,而沒有方法或事件觸發alert,那麼頁面上也不會alert。br;如果寫在body;/body;中,而沒有被觸發,那就是因為上面說的異常了。br;br;如果你使用IE瀏覽器測試,可以點擊左下角的狀態欄,查看javascript錯誤。br;其他瀏覽器一般也有類似的錯誤查看器,通常在菜單裡面。

2. JSP中使用alert的問題

<body>
<%--文本框設置 --%>
<!-- 這里加了提交檢測 -->
<form action="/evaluation" method="post" onsubmit="return check();">
<center>
Please input training data in the box below<br>

<div><textarea name="traindata" rows="5" cols="100"></textarea></div>
<br><br>
Please input evaluating data in the box below
<div><textarea name="dodata" rows="5" cols="70"></textarea></div>
<br><br>
Please select the model:
<input type="radio" name="button" value="button1" > B
<input type="radio" name="button" value="button2" > S
<br><br>
<div><input type="submit" value="Evaluation" /></div>
</center>
</form>

<script>
function check(){
//獲取按鈕組
var buttons = document.getElementsByName("button");
for(var i=0;i<buttons.length;i++){
//循環,如果有選擇的,就返回true
if(buttons[i].checked){
return true;
}
//如果都沒有選擇,返回false
alert("單選按鈕必須選一個");
return false;
}
}
</script>

</body>

<!-- 你現在把body內的內容都替換掉,我測試過,可以的。 -->

3. 怎麼在jsp中使用javascript的alert

||看下這個吧

User userSession=(User) session.getAttribute("LOGINEN_USER");
if(userSession == null || userSession.getStatus()!=0){
out.print("<script type='text/javascript'>alert('您尚未登版錄或者權超時');</script>");
out.print("<script type='text/javascript'>location.href='../login.jsp'</script>");
}

4. JSP中 alert不顯示的問題

您好,下面的,您看看,改了一下:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<! HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>
用戶登錄
</title>
<script language="JavaScript" type="text/javascript">

function userLogin(){

var userName=document.getElementById("username");
var password=document.getElementById("password");
if(userName.value == "" && userName.value.length<5){
alert("請輸入用戶名!")
userName.focus();
return false;
}else if(password.value == "" && password.value.length<5){
alert("請輸入用戶密碼!");
password.focus();
return false;
}else{

return true;
}
}
function userReg(){
document.frmAction.action="user_add.jsp";
document.frmAction.submit();
}
</script>
</head>
<body bgcolor="#ffffff">
<br>
<br>
<br>
<br>
<FORM method="POST" name="frmAction" >
<table border="1px #76aef0 solid" cellspacing="0" cellpadding="1" align="center" bgColor="#E4E8EF">
<tr>
<td width="50%">用戶名:</td>
<td width="50%"><input type="text" name="username" /></td>
</tr>
<tr>
<td width="50%">密碼:</td>
<td width="50%"><input type="password" name="password"/></td>
</tr>
<tr>
<td width="50%" align="center">
<input type="button" onClick="userLogin()" value="登錄" />
</td>
<td width="50%" align="center">
<input type="button" onClick="userReg()" value="注冊" />
</td>
</tr>
</table>
</FORM>
</body>
</html>

5. 在jsp里的使用alert列印

首先你的代碼有錯:
1. language屬性名拼寫錯誤,不過這個在IE裡面應該不會引起內問題。容
2. alert(request.getAttribute(err)); 這一句會引起javascript異常,至少應該寫成這樣:alert('<%=request.getAttribute(err)%>');。

另外,你這段代碼寫在login.jsp的什麼位置?
是在<head></head>中,還是在<body></body>中?
如果寫在<head></head>中,而沒有方法或事件觸發alert,那麼頁面上也不會alert。
如果寫在<body></body>中,而沒有被觸發,那就是因為上面說的異常了。

如果你使用IE瀏覽器測試,可以點擊左下角的狀態欄,查看javascript錯誤。
其他瀏覽器一般也有類似的錯誤查看器,通常在菜單裡面。

6. 怎麼在jsp中使用javascript的alert

User userSession=(User) session.getAttribute("LOGINEN_USER");

if(userSession == null || userSession.getStatus()!=0){

out.print("<script type='text/javascript'>alert('您尚未登錄或者超時');</script>");

out.print("<script type='text/javascript'>location.href='../login.jsp'</script>");

}

7. jsp里alert彈出對話框後在刷新本頁面怎麼寫

alert後直接寫刷新代碼即可,彈出來以後點了確定就直接按順序執行下面的代碼
第一種:
< script language="javascript"type="text/javascript">
window.location.href="http://www..com";
< /script>
第二種:
< script language="javascript">
alert("返回");
window.history.back(-1);
< /script>
第三種:
< script language="javascript">
window.navigate("http://www..com");
< /script>
第四種:
< script language="JavaScript">
self.location='http://www..com';
< /script>
第五種:
< script language="javascript">
alert("非法訪問!");
top.location='http://www..com';
< /script>

閱讀全文

與jsp下alert相關的資料

熱點內容
怎麼讓文件中全體內容往下移 瀏覽:783
魔獸爭霸126版本轉換器 瀏覽:984
word2003精簡版下載 瀏覽:703
微博跳轉appstore 瀏覽:537
打開文件時許可權a代表什麼 瀏覽:155
昆侖通態導出數據文件名 瀏覽:338
手機遷移數據為什麼需要重新登錄 瀏覽:958
錄入資料庫的圖片如何更改 瀏覽:132
怎樣獲取郵箱帳號和密碼 瀏覽:809
怎麼通過js實現回到指定頁面 瀏覽:140
如何用網路簽字 瀏覽:552
三星電視拆機教程 瀏覽:19
創維怎麼連接網路 瀏覽:868
2007版word繪圖在哪裡 瀏覽:311
可以拍車牌的app是什麼 瀏覽:508
文件加個井字型大小什麼意思 瀏覽:155
怎麼刪除多重網路 瀏覽:999
求生之路2區域網聯機工具 瀏覽:827
說明文件結尾用什麼詞 瀏覽:578
發送的文件名變數字 瀏覽:778

友情鏈接