webForumDet fria alternativet

kolla upplösningar?

ASP

2 svar · 180 visningar · startad av tigger

Medlem sedan feb. 200125 inlägg
Frågan#1

Hej!
Är det någon som vet hur man kollar vilken upplösning en besökare har? T ex om man vill göra en Response.Redirect till en annan sida om de sitter
på 800x600?

------------------
//Tigger

Medlem sedan dec. 199949 inlägg
#2

Jag vet tyvärr inte hur man gör i ASP, men det fungerar med ett javascript... Här kommer ett som jag vet fungerar. Lägg in en bild på 1x1 pixlar innanför <body> taggen och sätt width till 100%. Då känner scriptet av hur bred sidan är och redirectar efter det. Ett litet problem är bara att användaren bör ha sin webbläsare maximerad när han accessar sidan, annars blir upplösningen felaktig.

function afterLoad() {

//====== KONTROLLERAR ANVÄNDARENS WEBBLÄSARE ========
window.onerror=null;
var ns4 = 0;
var ie4 = 0;
var ns3 = 0;
var nojs = 0;

if (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) >= 4) {
	ie4 = 1;
} else if (navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 4) {
	ns4 = 1;
} else if (navigator.appName == "Netscape" && parseInt(navigator.appVersion) == 3) {
	ns3 = 1;
} else {
	nojs = 1;
}

//====== HÄMTAR SKÄRMUPPLÖSNING FÖR INTERNET EXPLORER ========
if (ie4) {
	windowWidth = document.images.sidBredd.width;

//====== HÄMTAR SKÄRMUPPLÖSNING FÖR NETSCAPE NAVIGATOR ========	
} else if (ns4) {
	windowWidth = window.innerWidth;
}

if (ie4 &#0124;&#0124; ns4) {
//====== OM 1024x768 & IE ELLER NN ========
	if (windowWidth > 900) {
		orgURLLength = top.location.href.length;
		orgURL = top.location.href;
		newURLStart = orgURLLength - 11;
		
		if (orgURL.substr(newURLStart) != "default.asp") {
			newURL = orgURL + "frameset.asp?res=1024x768";
			top.location.href = newURL;
			
		} else {
			newURL = orgURL.substr(0, newURLStart) + "frameset.asp?res=1024x768";
			top.location.href = newURL;
		}

//====== ANNARS OM 800x600 & IE ELLER NN ========		
	} else {
		orgURLLength = top.location.href.length;
		orgURL = top.location.href;
		newURLStart = orgURLLength - 11;
		
		if (orgURL.substr(newURLStart) != "default.asp") {
			newURL = orgURL + "frameset.asp?res=800x600";
			top.location.href = newURL;
			
		} else {
			newURL = orgURL.substr(0, newURLStart) + "frameset.asp?res=800x600";
			top.location.href = newURL;
		}
	}

//====== ANNARS OM T.EX. MACINTOSH 1024x768 ========	
} else {
		orgURLLength = top.location.href.length;
		orgURL = top.location.href;
		newURLStart = orgURLLength - 11;
		
		if (orgURL.substr(newURLStart) != "default.asp") {
			newURL = orgURL + "frameset.asp?res=1024x768";
			top.location.href = newURL;
			
		} else {
			newURL = orgURL.substr(0, newURLStart) + "frameset.asp?res=800x600";
			top.location.href = newURL;
		}
}
}

------------------
/David

Medlem sedan feb. 200125 inlägg
#3

Tack!
Ska testa.
Lite svår dock att veta vilken storlek fönstret öppnas i...

------------------
//Tigger

261 ms totalt · 4 externa anrop · v20260731065814-full.86ec41c2
128 ms — deklarationer (db)
0 ms — hämta statistik (cache)
130 ms — hämta tråd, inlägg och bilagor (db)
123 ms — ändringar (db)