Solved

Syntax for ASP/Javascript pages

Posted on 2012-04-11
5
340 Views
Last Modified: 2012-04-11
I have an ASP/VBScript page in which I have the code below. it simply displays an object depending on condition. the code works well for ASP/VBscript pages. But I need code that does the same thing for an ASP/Javascript page. If i try the code below on an ASP/Javascript page I get syntax error

-- code --

<%If isIPad() then%>
IPAD CODE
<%Else%>
COMPUTER CODE
<%End If%>

-----------
0
Comment
Question by:amucinobluedot
  • 3
  • 2
5 Comments
 
LVL 17

Expert Comment

by:Anuroopsundd
ID: 37833572
var ua = navigator.userAgent;
var isiPad = /iPad/i.test(ua) || /iPhone OS 3_1_2/i.test(ua) || /iPhone OS 3_2_2/i.test(ua);



http://davidwalsh.name/detect-ipad
0
 

Author Comment

by:amucinobluedot
ID: 37833578
Sorry i need the code to look like

<%If isIPad() then%>
CODE 1
<%Else%>
CODE 2
<%End If%>

IF
XXXXXX
ELSE
XXXXXXX

Not interested in iphone etc. just the ipad
0
 
LVL 17

Expert Comment

by:Anuroopsundd
ID: 37833582
var isiPad = navigator.userAgent.match(/iPad/i) != null;
 if (isiPad)
 {}
else
{}
0
 

Author Comment

by:amucinobluedot
ID: 37833592
I am not much of a coder, I already have the code that detects the devide on a separate file, thats not what I need. I include the file in my ASP.
The code I need is in the HTML part of the page that displays a form and will display text depending on the returned value if its an ipad or not, but i dont really need to code to detect it, already got that part.
0
 
LVL 17

Accepted Solution

by:
Anuroopsundd earned 500 total points
ID: 37833619
<script language="Javascript">
function isIPad() {
    alert(Request.ServerVariables("HTTP_USER_AGENT") );
    var isIpad = false;
    alert( Request.ServerVariables("HTTP_USER_AGENT") );
    if ( userAgent.indexOf("iPad") >= 0 ) {
        isIPad = true;
         return isIpad;
    } else {
    }
}
</script>
</body>
</html>
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
jQuery Parallax 1 38
CSS Position not returning 2 46
SharePoint 2013 List with Ratings 6 32
jquery conditionally populate list boxes 2 21
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now