Reply
Resolution Detection, Image Swapping
Old 03-31-2005, 02:00 AM Resolution Detection, Image Swapping
Luckboy's Avatar
Junior Talker

Posts: 1
A while back I saw a javascript that would swap out images of different sizes based upon the size of the browser window. Do any of you have a copy of that script, and is that technology reliable?
Luckboy is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 03-31-2005, 04:02 PM
pappasaa's Avatar
Extreme Talker

Posts: 231
you can use a javascript a sniffer that detects the page size, then based on that redirects them to a page that will fit their resolution. It's kind of a painful way of getting around that problem, because you would have to make 3 different websites with different sizes.... if you dont want to do that just make your page compatible for 1024x768 and most people wont have a problem with it.


Code:
<script language="text/javascript"> 
<!-- 
if(screen.width>=1280||screen.height>=1024){ 
var sTargetURL = "bigscreen.html"; 
}else if(screen.width=1024||screen.height=768){ 
var sTargetURL = "normalscreen.html"; 
}else if (scren.width<=800||screen.height<=600){ 
var sTargetURL = "smallscreen.html"; 
}else{ 
var sTargetURL = "normalscreen.html"; 
alert("Your current resolution settings do not match the content of this page.  Your current resolution is "+screen.width+" by "+screen.height+".  If possible please change your resolution to either 800x600, 1024x768, or 1280x1024."); 
} 

function doRedirect() 
{ 
    setTimeout( "window.location.href = sTargetURL", 500 ); 
} 

//--> 
</script> 

<body onload="doRedirect()">
if i got all that correctly, what it should do is check the resolution, if it is 1280x1024 or higher, it will redirect to bigscreen.html. if it is 1024x768, normalscreen.html, and if equal to or less than 800x600, smallscreen.html. If the user has a resolution somewhere in-between those three then it will politeley send an alert telling them that their resolution is different than what is best for the page, and ask them to change to one of the three choices.

what you need to do, is make those three pages, and put the function "doRedirect()" in the onLoad of your body tag.
__________________
Sheep go to heaven....Goats go to hell...
PoliticalJib.com | ArrogantRant.com | BigInfo.org | MyNewsPlus.com |<- Bloggers Wanted
pappasaa is offline
Reply With Quote
View Public Profile Visit pappasaa's homepage!
 
Old 03-31-2005, 04:17 PM
brokensoul2271's Avatar
- - - - - - - - -

Posts: 750
Location: Lancashire, UK
http://webreference.com/programming/javascript/images/ -might help...
__________________
Yes, indeed...
WebDevWorld.net | StrangeDarkness.com | MyNEWBlog
brokensoul2271 is offline
Reply With Quote
View Public Profile Visit brokensoul2271's homepage!
 
Old 03-31-2005, 05:21 PM
pappasaa's Avatar
Extreme Talker

Posts: 231
brokensoul2271

i like that tutorial but do you know if it will work in other browsers besides ie and netscape? Looks like it will just ignore if its not ie or nescape. just a question. I am going to test it out
__________________
Sheep go to heaven....Goats go to hell...
PoliticalJib.com | ArrogantRant.com | BigInfo.org | MyNewsPlus.com |<- Bloggers Wanted
pappasaa is offline
Reply With Quote
View Public Profile Visit pappasaa's homepage!
 
Old 03-31-2005, 05:23 PM
brokensoul2271's Avatar
- - - - - - - - -

Posts: 750
Location: Lancashire, UK
i really dont know... please let me know after you have tested it
__________________
Yes, indeed...
WebDevWorld.net | StrangeDarkness.com | MyNEWBlog
brokensoul2271 is offline
Reply With Quote
View Public Profile Visit brokensoul2271's homepage!
 
Old 03-31-2005, 05:31 PM
pappasaa's Avatar
Extreme Talker

Posts: 231
i will check it out and get back to you
__________________
Sheep go to heaven....Goats go to hell...
PoliticalJib.com | ArrogantRant.com | BigInfo.org | MyNewsPlus.com |<- Bloggers Wanted
pappasaa is offline
Reply With Quote
View Public Profile Visit pappasaa's homepage!
 
Reply     « Reply to Resolution Detection, Image Swapping
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.13119 seconds with 12 queries