導航:首頁 > 編程語言 > 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相關的資料

熱點內容
ps文件模糊 瀏覽:192
葉檀財經推出過什麼購物APP 瀏覽:875
linux硬碟檢測 瀏覽:431
如何用路由器降低網路延遲 瀏覽:601
aix分區root密碼 瀏覽:439
運動鞋買鞋上什麼app 瀏覽:904
NSA工具下載 瀏覽:918
函數代碼在哪個文件夾 瀏覽:213
微信應用怎麼代碼添加快捷方式 瀏覽:371
用數據說話是最有力的什麼 瀏覽:27
圖片文件被鎖定無法打開 瀏覽:768
wr886nv2升級 瀏覽:490
移動硬碟視頻文件無法刪除 瀏覽:417
如何查看網路監控 瀏覽:132
列印機如何連接到網路列印機 瀏覽:181
vmlinux安裝tools 瀏覽:768
波形文件轉mp3 瀏覽:803
linux查看網路 瀏覽:163
如何從cad軟體里列印命令文件 瀏覽:247
clover780ti黑蘋果 瀏覽:928

友情鏈接