Resolution specific delivery

This is a discussion on "Resolution specific delivery" within the JavaScript Forum section. This forum, and the thread "Resolution specific delivery are both part of the Program Your Website category.



 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1  
Old May 13th, 2006, 09:47
Junior Member
Join Date: Jan 2006
Location: West Wycombe
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Resolution specific delivery

I hope I've posted this in the correct forum, I'm sure the answer will be Javascript.

Is there someway that I can check the resolution of a browser and then deliver the appropriately sized page?

Thank you
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old May 13th, 2006, 15:20
Up'n'Coming Member
Join Date: Mar 2006
Location: East Sussex, UK
Age: 20
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Resolution specific delivery

Code: Select all
if (parseInt(navigator.appVersion)>3) {
 if (navigator.appName=="Netscape") {
  winW = window.innerWidth;
  winH = window.innerHeight;
 }
 if (navigator.appName.indexOf("Microsoft")!=-1) {
  winW = document.body.offsetWidth;
  winH = document.body.offsetHeight;
 }
}

document.write(
 "Window width = "+winW+"<br>"
+"Window height = "+winH
)
Then you just need to add the page information for certain sizes, using a case statement or an If statement if there are only two outputs.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old May 13th, 2006, 15:47
Junior Member
Join Date: Jan 2006
Location: West Wycombe
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Resolution specific delivery

Thank you very much indeed darryladie for the code, unfortunately I don't know how to implement it or construct the "case statement" or "if statement".

Ideally, if the visitor is 800x600 they would go to index1.htm and if they're at 1024x768 or bigger they would go to index2.htm
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old May 13th, 2006, 16:23
Up'n'Coming Member
Join Date: Mar 2006
Location: East Sussex, UK
Age: 20
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Resolution specific delivery

OK, to redirect the user based on their resolution do the following:

Code: Select all
if (parseInt(navigator.appVersion)>3) {
 if (navigator.appName=="Netscape") {
  winW = window.innerWidth;
  winH = window.innerHeight;
 }
 if (navigator.appName.indexOf("Microsoft")!=-1) {
  winW = document.body.offsetWidth;
  winH = document.body.offsetHeight;
 }
}
if (winW<768) {
document.write('<META HTTP-EQUIV=Refresh CONTENT="1; URL=index2.htm>')
}
If you load index1.htm first, then if the user needs it the browser will redirect to the new page (index2.htm). Hope this helps (and works - I havent tested it)

Last edited by darryladie; May 13th, 2006 at 16:26.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old May 13th, 2006, 16:31
Junior Member
Join Date: Jan 2006
Location: West Wycombe
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Resolution specific delivery

Thank you darryladie, I shall try it straight away!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old May 13th, 2006, 20:22
Junior Member
Join Date: Jan 2006
Location: West Wycombe
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Resolution specific delivery

I'm afraid it didn't work.

I try placing it in different parts of the page but it appeared in view so I put script tags around it, it disappeared from view and I got the impression that it was trying to work but it didn't load index2.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old May 14th, 2006, 13:59
Up'n'Coming Member
Join Date: Mar 2006
Location: East Sussex, UK
Age: 20
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Resolution specific delivery

Yeh you're right it doesn't, this now does, in both IE and FF:

Please this in your <head>:

Code: Select all
<script type="text/javascript">
function loadPage() {

      winW = window.innerWidth;
      winH = window.innerHeight;
        
     if (navigator.appName.indexOf("Microsoft")!=-1) {
      winW = document.body.offsetWidth;
      winH = document.body.offsetHeight;
     }
    
    if (winW<768) {
    document.write('<META HTTP-EQUIV="Refresh" CONTENT="1; URL=http://www.google.com/">')
    }
}
</script>
And change the <body> tag so it looks like this:

Code: Select all
<body onload="loadPage()">
Darryl
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old May 14th, 2006, 15:11
Junior Member
Join Date: Jan 2006
Location: West Wycombe
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Resolution specific delivery

Thank you Darryl, I'll give it it try
Kind regards
Mike
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9  
Old May 15th, 2006, 11:17
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Resolution specific delivery

Why are you taking this approach in the first place?

Better to use css and design you pages to work at whatever size the browser happens to be.

Also you don't then have the problem of maintaining more than one version of any particular page.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10  
Old May 15th, 2006, 11:36
Junior Member
Join Date: Jan 2006
Location: West Wycombe
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Resolution specific delivery

Thank you Darryl, you're right, this one does work.

Again many thanks for helping me solve the problem, hopefully I can return the favour one day.

Kind regards

Mike
(Thread closed)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
resolution, specific, delivery

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Resolution problem A800 Web Page Design 3 Mar 11th, 2008 20:40
Loading specific flash movies for specific pages koonkle Flash & Multimedia Forum 3 May 22nd, 2007 17:23
ASP / ASP. Net Software Delivery Engineer - Oxford - Client-facing Web JobBot Job Opportunities 0 Feb 8th, 2007 16:40
How can I know the user's resolution QuikFrozen JavaScript Forum 5 Aug 9th, 2006 15:03
Resolution Fix Udabar JavaScript Forum 6 Apr 10th, 2006 02:23


All times are GMT. The time now is 04:00.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42