Home > Web Front-end > HTML Tutorial > Develop a website that is compatible with PC access and mobile phone access. _html/css_WEB-ITnose

Develop a website that is compatible with PC access and mobile phone access. _html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:16:38
Original
1393 people have browsed it

The company has developed a portal website. There is no problem when accessing it on a PC. However, when accessing it with the browsing ball that comes with a mobile phone, there are problems with the layout and the layout is very poor.
My idea is whether it is possible to determine whether the user is accessing the website from a mobile phone or using a PC. If so, we can do two sets of things. The PC accesses the portal website with rich layout, and the mobile phone accesses the streamlined version. website.
If not, I hope the experts can give me a solution.


Reply to the discussion (solution)

There must be two sets of pages accessed by PC and mobile phone. The pages on PC have a lot of content, but the pages on mobile phones generally need to be streamlined. How to call and judge should be a matter for programmers, I don’t know, haha ​​

Search for HTTP_ACCEPT

You can consider making a portal and choose whether to enter the PC or mobile page.

Today’s browsers on smartphones are basically not much different from actual PC browsers (except for speed). As long as your page meets W3C standards, it should be displayed the same.
If you must distinguish between browsers, you can look at userAgent. Each browser has a unique userAgent. userAgent can be obtained on the client via
window.navigator.userAgent
. On the server side, it depends on what technology you use. Generally, it will be mentioned in the documentation.

Today’s browsers on smartphones are basically not much different from actual PC browsers (except for speed). As long as your page meets W3C standards, it should be displayed the same .
If you must distinguish between browsers, you can look at userAgent. Each browser has a unique userAgent. userAgent can be obtained on the client via
window.navigator.userAgent
. On the server side, it depends on what technology you use. Generally, it will be mentioned in the documentation.

I don’t want to distinguish which browser is accessed now, I want to distinguish whether it is accessed using a mobile phone or a computer. UserAgent can only distinguish which browser is used.

This is very easy, just make two sets of CSS style sheets with different layouts, and then like the following:

The principle of this is not to judge on your side, but to use the functions of the browser itself on your computer or mobile phone to achieve it. Because they themselves will check the CSS that best meets their requirements. If you do not specify the CSS suitable for mobile phones, it can only use the solution for computers, so the effect is not ideal.

There is no need to do anything like this yourself. Learn to take advantage. Of course, for non-smartphones, if you use WML or the like, then your website must be converted. But you seem to exclude them, which is correct and unnecessary.

It can be judged by using js. For example: !/((iPhone|iPad|iPod)/i.test(navigator.userAgent) This only judges whether it is an Apple handheld device. You can also judge. Others

Pay attention!

This is very easy, just make two sets of CSS style sheets with different layouts, and then do as follows:

...
I also plan to make two sets.
The current problem is to achieve automatic jump. For example, my project is deployed under www.myWebSite.com. There are three html in the project directory, namely index.html, computer.html, and telphone.html. The user enters by default Under index.html, it is determined whether the user enters from a mobile phone or a computer. If the user enters from a mobile phone, it will enter telphone.html. If the computer enters, it will enter computer.html

servlet

servlet
Can you be more detailed?

Quoting the reply from theforever on the 7th floor:
This is very easy. Just make two sets of CSS style sheets with different layouts, and then like the following:

I also plan to make two sets of things.
The problem now is to realize automatic jump.
The two sets I mentioned are not the two sets you think.
The two sets you want are from HTML to CSS and even to the whole image.
I mean two sets, just CSS, the page is still one page, so there is no need to jump at all. Depending on the device, different CSS solutions will naturally be called. As long as you arrange the page layout and write the CSS well, one page will produce two completely different display effects suitable for different devices.

As for the method for the program to detect the device and then jump, it can be implemented in both the background and the foreground.
But in that case, two sets of things are time-consuming and labor-intensive to make, and more troublesome to maintain. If one part changes, the other must be modified simultaneously.
My method is to consider allowing you to achieve it at the lowest cost now and in the future.

As for the method for the program to detect the device and then jump, it can be implemented in both the background and the foreground.
But in that case, two sets of things are time-consuming and labor-intensive to make, and more troublesome to maintain. If one part changes, the other must be modified simultaneously.
My method is to consider allowing you to achieve it at the lowest cost now and in the future.
The current requirement is that two sets must be made, because the contents of the two accesses are completely different. There are only two modules that can be accessed by mobile phones, "FAQ" and "Software Download", but there are many more contents that can be accessed by computers. . In the end, the discussion decided to make two sets, including pages, css and pictures.
You said above that it is easy to detect device jumps. Can you tell me your method?

Unless the mobile browser and PC browser can obtain differentiated information using JS, it is impossible.

And whether the user surfs the Internet on a mobile phone or a computer, strictly speaking, it is personal privacy.

Pay attention... I don’t know how the industry implements it? For example, wap.sina.com

How to make a mobile website, experts can teach me

I don’t know about the poster’s problem Have you solved it? I also encountered the same problem, that is, the PC and mobile websites are two completely different pages. I just need to distinguish them. I don’t know what to do. The poster is asking if you can help me if you have solved the problem. Please tell me. Thank you.

js determines what is the system platform of the browser used in the navigator object

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template