JavaScript函數在頁面加載時被調用,它返回多個值,我需要接收這些值。我應該在form或body標籤中指定哪些內容以便在我的jsp頁面中使用這些值?如何從javascript函數接收多個值?
我使用的代碼是:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript">
function Browser()
{
var myWidth;
var myHeight;
if(typeof(window.innerWidth) == 'number') {
//Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
} else if(document.documentElement &&
(document.documentElement.clientWidth || document.documentElement.clientHeight)) {
//IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
} else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
//IE 4 compatible
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}
return {myWidth:myWidth, myHeight:myHeight};
}
</script>
</head>
<body onload="Browser()">
<form name="hello" action="" method="post" >
<table align="center" border="1">
<tr>
<td>
User Name:
</td>
<td>
<input type="text" name="user"/>
</td>
</tr>
<tr>
<td>
Password:
</td>
<td>
<input type="password" name="pwd"/>
</td>
</tr>
<tr align="center">
<td colspan="2">
<input type="submit" value="Submit"/>
</td>
</tr>
</table>
</form>
</body>
</html>
在上面的代碼功能瀏覽器將返回的分辨率值和我 一直使用的onload()方法調用該函數。我應該如何收到myWidth和myHeight的 值,以便在同一個jsp頁面中使用它們?
很多表格單元格! –