Use JS distinguish client

Before meeting, the supervisors such an indication.

He said: "Look, can you help me out, ipad comes with the keyboard problem."

What we did this project, it is a web project, and then ask the computer terminal and the tablet can access. Date input box in place. They do have a date of their own control, you can select a date.

In the flat end, the point about the date, the following will play the ios built-in keyboard. The keyboard, accounted for almost one-third more than the screen, place, cause, make their own date control obscured.

 

Then the thing came. Let me go investigate.

Find meal.

We found that the readonly written on it.

But there are problems.

 

PC side, you can not enter the desired date.

 

Is required, the computer side, not readonly.

 

So there is the following code:

 

js end:

 

was isBrowserSafari = false;

.. If (navigator.userAgent.match (/ (iPhone | iPod | iPad | Android * Mobile) / i) {// front end of the corresponding non-computer to write this case safari browser: (/ (Safari) / i )

  isBrowserSafari = true;

}

else

{

  isBrowserSafari = false;

}

 

var MyDate = document.getElementById(“MyDate”);

if(isBrowerSafari){

  MyDate.setAttribute("readonly","true");

}

else{

  // no treatment

}

 

 

Probably the case ~ ~ ~

Guess you like

Origin www.cnblogs.com/letben/p/js.html