Javascript - zmiana strony w/g rozdzielczości (48)
Javascript · 07.07.04 11:43 · 24.06.06 20:06
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
</head>
<script language="JavaScript"><!--
var url640 = "640.htm";
var url800 = "800.htm";
var url1024 = "1024.htm";
var url1152 = "1152.htm";
if(screen.width<800||screen.height<600) window.location.href= url640;
else if(screen.width<1024||screen.height<768) window.location.href= url800;
else if(screen.width<1152||screen.height<864) window.location.href= url1024;
else if(screen.width>=1152||screen.height>=864) window.location.href= url1152;
--></script>
<body bgcolor="#FFFFFF" text="#000000">
</body>
</html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
</head>
<script language="JavaScript"><!--
var url640 = "640.htm";
var url800 = "800.htm";
var url1024 = "1024.htm";
var url1152 = "1152.htm";
if(screen.width<800||screen.height<600) window.location.href= url640;
else if(screen.width<1024||screen.height<768) window.location.href= url800;
else if(screen.width<1152||screen.height<864) window.location.href= url1024;
else if(screen.width>=1152||screen.height>=864) window.location.href= url1152;
--></script>
<body bgcolor="#FFFFFF" text="#000000">
</body>
</html>
szybki ajax (72)
Javascript · 29.01.09 16:23 · 29.01.09 16:35
1. plik: testhtml.html (otwarty w przeglÄ…darce z serwera www np. z lokalnego)
<html>
<head>
<script type='text/javascript'>
function ajax(id,url) {
var xmlHttp;
try {
xmlHttp = new XMLHttpRequest();
}
catch(e) {
try {
xmlHttp = new ActiveXObject("Msxml2.HMLHTTP");
}
catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {
alert("Twoja przegladarka nie obsluguje AJAX'a!");
return false;
}
}
}
xmlHttp.onreadystatechange = function() {
if ( xmlHttp.readyState==4 ) {
document.getElementById(id).innerHTML = xmlHttp.responseText;
}
}
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
</script>
</head>
<body>
<div id='test'></div>
<button onClick="ajax('test','testaja.php')">pobierz</button>
</body>
</html>
- - -
2. plik: testaja.php (na serwerze np. lokalnym)
<?php
echo 'Ala + kota';
?>
<html>
<head>
<script type='text/javascript'>
function ajax(id,url) {
var xmlHttp;
try {
xmlHttp = new XMLHttpRequest();
}
catch(e) {
try {
xmlHttp = new ActiveXObject("Msxml2.HMLHTTP");
}
catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {
alert("Twoja przegladarka nie obsluguje AJAX'a!");
return false;
}
}
}
xmlHttp.onreadystatechange = function() {
if ( xmlHttp.readyState==4 ) {
document.getElementById(id).innerHTML = xmlHttp.responseText;
}
}
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
</script>
</head>
<body>
<div id='test'></div>
<button onClick="ajax('test','testaja.php')">pobierz</button>
</body>
</html>
- - -
2. plik: testaja.php (na serwerze np. lokalnym)
<?php
echo 'Ala + kota';
?>
