Solved

ipad display not ipad dont display

Posted on 2012-04-09
3
298 Views
Last Modified: 2012-04-10
I have been posting some code to do this but seems like its just more confusing, so ill keep things simple.
I am using ASP/Javascript page. I need to display a form in my page if a user is using an ipad and if they are not then display someting else, so .. simple as this:

If user is using ipad display "I am using ipad", if not display "I am using a computer"

thats it.
I am assuming this will require some javascript and some asp to display the conditional region based on the value passed by the javascript .. again .. i am not the expert.  I already have this code for an ASP/VBscript page and works like a charm, something simple like that would work. Attached is the ASP/VBscript code to use as reference if it is of any help.
ipadcode.txt
0
Comment
Question by:amucinobluedot
  • 2
3 Comments
 
LVL 15

Expert Comment

by:pateljitu
ID: 37824768
Your code looks OK for identifying USER_AGENT, only change would be you body part i.e:

<%If isIPad() then%>
    using ipad
<%Else%>
    Not using ipad
<%End If%>

Open in new window


Please also have a look at this article:
http://mobiforge.com/developing/story/lightweight-device-detection-asp

in this sample on line as below add ipad:
.Pattern = "(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|windows ce|pda|mobile|mini|palm|ipad)"
0
 

Author Comment

by:amucinobluedot
ID: 37825323
I know, that is VBScript which works just fine. I need that in JAVASCRIPT
0
 
LVL 15

Accepted Solution

by:
pateljitu earned 500 total points
ID: 37826090
Please try this javascript code:

<script type="text/javascript" language="javascript">

var isiPad = navigator.userAgent.match(/iPad/i) != null;

function checkUserAgent()
{
    alert(navigator.userAgent);
    if(isiPad){
        alert("using ipad");
        document.getElementById("usingiPad").style.display = "";
    }else{
        alert("Not using ipad");
        document.getElementById("usingDesktop").style.display = "";
    }
}
</script>


<div  id="usingiPad" style="display:none;">
    Using iPad
   <form id="someform"></form>
</div>

<div id="usingDesktop" style="display:none;">
    Using Desktop
</div>


<!--End of the page-->
<script type="text/javascript" language="javascript">
    function setSequence(){
        if (document.addEventListener) {
          document.addEventListener("DOMContentLoaded", checkUserAgent(), null);
        }
        window.onload = checkUserAgent();
    };
    setSequence();

</script>

Open in new window

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
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…

759 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

25 Experts available now in Live!

Get 1:1 Help Now