Send variabel med JS
Jeg er i tvivl om hvordan jeg får sendt en variabel fra en side til en anden med JavaScript. Det jeg skal er at aflæse den første sides browserhøjde og derefter sende den til den næste side.Jeg forestiller mig at man skal bruge en skjult formular men jeg kender ikke JavaScript godt nok til at kunne skrive indholdet af en variabel ned i formularen. Jeg har bl.a. taget udgangspunkt i denne tråd:
http://www.eksperten.dk/spm/542531
<html>
<head>
<script type="text/javascript">
function alertSize() {
var myWidth = 0, myHeight = 0;
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;
}
}
</script>
</head>
<body>
<form action="nytvindue.php" method="post" name="minForm">
<input type="hidden" name="hojde" value="[Hvordan indsættes min variabel her??]">
</form>
<a href="#" onclick="document.minForm.submit();return false;">send højde</a>
</body>
</html>
Jeg vil helst have dette gjort vha. POST.
På forhånd tak.
