About judging whether web is accessed by mobile phone or computer, and the implementation of copy and delete button
As smartphones become more and more popular, more computer applications will launch mobile phone versions, such as websites. As computers and mobile phones visit the page when the js,css will be different, so you need to determine whether the phone or computer login, to display different pages to achieve a better user experience!
One: the method to determine whether the mobile end or the computer side accesses WEB.
1.js judgment
Var useragent=window.navigator.userAgent
Alert (useragent)
Useragent is some information of the browser, for example, when I access it with a computer browser, it will pop up (using an IE10,chrome,safari,firfox browser to do an experiment)
When the mobile browser is accessed, it pops up (the phone uses an opera analog browser)
In this way, you can use functions such as indesof,contains to judge and jump to different pages.'
2.java
In fact, in java code, it is very similar to js judgment, my method is:
If (userAgents.indexOf ("Windows")! =-1) {
Return new DefaultHttpHeaders ("computer side Jump Page jsp name"). DisableCaching ()
}
Else {
Return new DefaultHttpHeaders ("Mobile Jump Page jsp name"). DisableCaching ()
}
I operate in this way, there must be other ways, please leave a message to tell me, little brother very much thank you first!