여러 값을 반환하는 페이지 로딩 할 때 javascript 함수가 호출되고 해당 값을 받아야합니다. 내 JSP 페이지에서 그 값을 사용하도록 양식이나 본문 태그에서 무엇을 지정해야합니까?자바 스크립트 함수에서 여러 값을받는 방법은 무엇입니까?
내가 사용 코드는 : 상기 코드 기능 탐색기
<!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>
해상도 값을 반환하고 난 는 온로드() 메소드를 이용하여 그 기능을 호출 하였다. 같은 JSP 페이지에서 사용할 수 있도록 어떻게 myWidth 및 myHeight 값을 받습니까?
return {myWidth:myWidth, myHeight:myHeight};
그것은 다음과 같이 다른 자바 스크립트를 사용할 수 있습니다 :
는var dimension = Browser();
var width = browser.myWidth;
var height = browser.myHeight;
당신은 서버에서 이러한 변수에 액세스 할 수 없습니다 (하지 않는 한
많은 표 셀에! –