Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Javascript Detection

Featured Replies

Hey,

 

Im currently using the following code to detect iphone/itouch devices, I was wondering if anyone knows the line of code I will need to add so if its not a iphone/itouch and not a PC it directs to that site. i.e if no javascript?

 

<script LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">

<!--

 

if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {

if (document.cookie.indexOf("iphone_redirect=false") == -1) window.location = "iphone site";

}

 

//-->

</SCRIPT>

Hey,

 

Im currently using the following code to detect iphone/itouch devices, I was wondering if anyone knows the line of code I will need to add so if its not a iphone/itouch and not a PC it directs to that site. i.e if no javascript?

 

<script LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">

<!--

 

if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {

if (document.cookie.indexOf("iphone_redirect=false") == -1) window.location = "iphone site";

}

else {

// put your code here

}

 

//-->

</SCRIPT>

 

I think the code you're thinking of is what I've added in bold, but you can't detect whether JavaScript is disabled.

 

What we tend to do is use JavaScript to enable itself. We keep JavaScript as an optional extra so that any website will still work without JavaScript (but work better with JavaScript enabled). It's a process known as "progressive enhancement" (a good explanation is on A List Apart) and it may help you better understand your own question :)

  • Author

I think the code you're thinking of is what I've added in bold, but you can't detect whether JavaScript is disabled.

 

What we tend to do is use JavaScript to enable itself. We keep JavaScript as an optional extra so that any website will still work without JavaScript (but work better with JavaScript enabled). It's a process known as "progressive enhancement" (a good explanation is on A List Apart) and it may help you better understand your own question :)

 

Thanks for the reply,

 

Currently the code I am using is to detect if the user is on an iphone or itouch, if they are it redirects them to the site I have designed especially for them. As you probablly already know but I have also created a more watered down version for WAP and older phones and im strugling with how to detect them and redirect thats why I was thinking of a if no javascript redirect here kind of thing. Do you have any idea how i could/should go about that?

Thanks for the reply,

 

Currently the code I am using is to detect if the user is on an iphone or itouch, if they are it redirects them to the site I have designed especially for them. As you probablly already know but I have also created a more watered down version for WAP and older phones and im strugling with how to detect them and redirect thats why I was thinking of a if no javascript redirect here kind of thing. Do you have any idea how i could/should go about that?

 

Why don't you check for screen size too then?

 

IF iDevice? Then send to iSite

ELSE IF Screen Size <= iPhone/Touch screen size? then send to WAP Site

ELSE Send to PC site.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.