?
Solved

Syntax for ASP/Javascript pages

Posted on 2012-04-11
5
Medium Priority
?
348 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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'…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…
Suggested Courses

801 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