Solved

Syntax for ASP/Javascript pages

Posted on 2012-04-11
5
337 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

706 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

18 Experts available now in Live!

Get 1:1 Help Now