我有以下脚本,我将scriptlet变量传递给javascript函数。但是没有警告框显示..请告诉我这里我想念的东西..
<script language="JavaScript">
window.onload = function(){
<%
String res = request.getParameter("Message");
%>
var Value = "<%=res%>";
alert(Value);
document.Form.submit();
};
</script>
提前致谢
答案 0 :(得分:1)
试试这个......
<script type="text/javascript">
window.onload = function(){
<%
String res = request.getParameter("Message");
%>
var Value = <%=res%>;
windows.alert(Value);
document.Form.submit();
};
</script>
答案 1 :(得分:1)
您需要使用的是<%= ... %>
。试试这个:
<script type="text/javascript">
window.onload = function(){
<%
String res = request.getParameter("Message");
%>
var Value = <%=res%>;
alert(Value);
document.Form.submit();
};
</script>
答案 2 :(得分:1)
@John为什么要在javascript中创建scriptlet标记。而是尝试使用它,
<%
String res = request.getParameter("Message");
%>
<script type="text/javaScript">
window.onload = function(){
var Value = "<%=res%>";
alert(Value);
document.Form.submit();
};
</script>
否则尝试使用jquery插件来实现您的目的,
<%
String res = request.getParameter("Message");
%>
<script type="text/javaScript">
$(document).ready(function() {
var Value = "<%=res%>";
alert(Value);
$('form#myForm').submit();
});
</script>