Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > redirect visitors based on both screen resolution and browser

Reply
Thread Tools

redirect visitors based on both screen resolution and browser

 
 
one.1more@gmail.com
Guest
Posts: n/a
 
      02-26-2007
Hello,
I have the following code but its not working. i want my site to be
accessible only if the visitors resolution is 1024 x 768 or higher and
only if they are using internet explorer. the version is not important
because i think most people have 5.5+
When i visit my my site with 800 x600 either by using firefox or IE,
it redirects me to useie.htm. but if i use firefox with 1024 x 768, it
doesnt redirect me to useie.htm. why? can someone fix my code?
Code:

<script language="javascript" type="text/javascript">
<!--
browserName = navigator.appName;
if ((screen.width<=1024) && (screen.height<=76&& (browserName!
="Microsoft Internet Explorer"))
{
window.location="http://mysite.com/useie.htm;
}
//-->
</script>

(i also tried putting var in front of browserName when its first
declared, it didnt work that way either)

 
Reply With Quote
 
 
 
 
Darko
Guest
Posts: n/a
 
      02-26-2007
On Feb 26, 2:00 pm, (E-Mail Removed) wrote:
> Hello,
> I have the following code but its not working. i want my site to be
> accessible only if the visitors resolution is 1024 x 768 or higher and
> only if they are using internet explorer. the version is not important
> because i think most people have 5.5+
> When i visit my my site with 800 x600 either by using firefox or IE,
> it redirects me to useie.htm. but if i use firefox with 1024 x 768, it
> doesnt redirect me to useie.htm. why? can someone fix my code?
> Code:
>
> <script language="javascript" type="text/javascript">
> <!--
> browserName = navigator.appName;
> if ((screen.width<=1024) && (screen.height<=76&& (browserName!
> ="Microsoft Internet Explorer"))
> {
> window.location="http://mysite.com/useie.htm;}
>
> //-->
> </script>
>
> (i also tried putting var in front of browserName when its first
> declared, it didnt work that way either)


Just simple use of logic in your if-expression. If you want to allow
only users that use both ie AND 1024x768, then you need to redirect
all the users that either don't have ie OR don't have 1024x768 or
higher. So the correct expression would be:
if ( (screen.width<1024 && screen.height<76 || (browserName !=
"Microsoft Internet Explorer") )
// redirect...

The easier way for you, if you're not aware of logical expressions
rules, would be the following: first write the expression that
recognizes users you want to ALLOW, and then negate the whole
expression:
if ( ! ((screen.width>=1024 && screen.height>=76 && (browserName ==
"Microsoft Internet Explorer")) )
// redirect...
Cheers

 
Reply With Quote
 
 
 
 
one.1more@gmail.com
Guest
Posts: n/a
 
      02-27-2007
On Feb 26, 12:02 pm, "Darko" <(E-Mail Removed)> wrote:
> On Feb 26, 2:00 pm, (E-Mail Removed) wrote:
>
>
>
> > Hello,
> > I have the following code but its not working. i want my site to be
> > accessible only if the visitors resolution is 1024 x 768 or higher and
> > only if they are using internet explorer. the version is not important
> > because i think most people have 5.5+
> > When i visit my my site with 800 x600 either by using firefox or IE,
> > it redirects me to useie.htm. but if i use firefox with 1024 x 768, it
> > doesnt redirect me to useie.htm. why? can someone fix my code?
> > Code:

>
> > <script language="javascript" type="text/javascript">
> > <!--
> > browserName = navigator.appName;
> > if ((screen.width<=1024) && (screen.height<=76&& (browserName!
> > ="Microsoft Internet Explorer"))
> > {
> > window.location="http://mysite.com/useie.htm;}

>
> > //-->
> > </script>

>
> > (i also tried putting var in front of browserName when its first
> > declared, it didnt work that way either)

>
> Just simple use of logic in your if-expression. If you want to allow
> only users that use both ie AND 1024x768, then you need to redirect
> all the users that either don't have ie OR don't have 1024x768 or
> higher. So the correct expression would be:
> if ( (screen.width<1024 && screen.height<76 || (browserName !=
> "Microsoft Internet Explorer") )
> // redirect...
>
> The easier way for you, if you're not aware of logical expressions
> rules, would be the following: first write the expression that
> recognizes users you want to ALLOW, and then negate the whole
> expression:
> if ( ! ((screen.width>=1024 && screen.height>=76 && (browserName ==
> "Microsoft Internet Explorer")) )
> // redirect...
> Cheers


it works. thank you

 
Reply With Quote
 
 
 
Reply

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
more unique visitors than visitors meltedown HTML 9 10-17-2006 09:43 AM
Screen placement based on screen resolution Pat Python 5 04-08-2006 03:10 PM
Using javascript to redirect visitors based on their search queries enterthe@walla.com Javascript 2 10-06-2005 05:17 PM
Basic Q - Response.Redirect, all redirect to first Response.Redirect statement Sal ASP .Net Web Controls 1 05-15-2004 03:46 PM
Detect and track visitors screen resolutions Brent Javascript 8 05-10-2004 03:24 AM



Advertisments