Solved

Syntax for ASP/Javascript pages

Posted on 2012-04-11
5
343 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 AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem to refer to value 8 50
is VBA going to die in another decade? what is the Office.JS is it going to replace VBA? 4 63
jqury 17 30
ASP server side get value 15 24
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…

832 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