Solved

Syntax for ASP/Javascript pages

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

691 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