Table of Contents
回复内容:
Home Web Front-end H5 Tutorial 在微信上做 HTML5 网页和普通的网页开发有何不同?

在微信上做 HTML5 网页和普通的网页开发有何不同?

Jun 07, 2016 am 08:42 AM

回复内容:

如果考虑的范围只是微信内置浏览器和手机上的浏览器应用(safari、chrome)的话,差不多有几个不同点吧:
  1. 最突出的差别,前端要注意分享功能!上线之前,每个页面基本都要review一边分享功能是不是完善的。
  2. 微信最近提供了新的接口,所以以后会有更多与微信贴合紧密的特性。
  3. html5接口上的差异。safari和chrome的话提供的html5接口会更多,而微信内置浏览器的接口比较少,印象最深的是usermedia。前几天在项目里还发现,微信里固定定位的支持还是不够好,safari在这点上现在好很多了。所以如果想让 web 应用在微信里体验更好一些的话,iscroll类的模块是免不了的。
  4. 微信浏览器的兼容性问题,在android上比较明显。印象比较深的是三星的机型上不支持background-size-cover,必须使用-webkit-background-size才行。小米的输入框比较难搞。。。
  5. 开发、调试上的问题。android chrome比较好,有远程调试功能。微信里面基本木有办法。遇到棘手的问题,一般会使用modernizr来做特性检测,或者使用远程log工具调试。相关工具有:
    • Console.Re | Remote JavaScript Development Console
    • Sentry: Track exceptions with modern error logging for JavaScript, Python, Ruby, Java, and Node.js
    • Modernizr Helper
H5,得通过JSSDK去调用微信很多内置接口,是网页版所没有的。
在微信上做 HTML5 网页和普通的网页开发有何不同? 说两个页面表现上的小差异,都是 webview 相对于手机浏览器的差异。

1. 在 iOS 上,Safari 里打开的页面在进入后台后会停止渲染行为和运行 js,但是在 webview (包括微信的里的 webview)里打开的页面,当应用进入后台时,并不会停止渲染行为,也不会停止运行 js,也不会触发页面可见性的变化,甚至帧率都不会降低。直到应用因内存不足被杀死之前页面都是正常运行的。
正是因为这个,微信里运行的网页好像没有什么办法可以知道自己是否进入了后台。

P.S. 其实帧率也不是完全不变的,webview 在进入后台时会有一个很短暂的帧率突然减小的行为,我根据这个写过一个通过分析帧率变化来判断页面是否进入后台的 demo,效果还不错。(注意,这个行为似乎不是由性能直接导致的,我在性能非常高的模拟器上跑 demo 依然是 work 的,帧率变化和真机上差不多)。但是影响帧率的因素太多了,而且我不知道原理是什么,所以没什么价值。

2. 在 webview 的一个 iframe 里如果有一个 target="_blank" 的链接,我们预期的行为是点击后在最外层页面打开链接,但是部分安卓机会直接在 iframe 里打开链接,有的 Android 4 以上的机器也有这个 bug(看标准应该算是 bug)。
这个是我之前在阿里妈妈实习时知道的,当时大大们发现我们运行在 webview 里的 iframe 广告,在一些安卓机里点击时会直接在小小的 iframe 框里打开,非常坑。
到现在我也不知道产生这个行为的原因是什么,搞安卓的小伙伴 @和林跃 说一些厂商会对 webview 作改动,可能是因为这个吧。

突然感觉答得有点 跑题,匿了。 有不少定制平台了,像云来,www.gaohuodong.me,maka,初页……
看看他们的案例会不会帮到你~ 微信上的H5更具有自我营销能力,带有病毒扩散功能,有带入感,更强调沉浸式体验,注重引导性逻辑,讲故事提问题引不同,引参与,诱转发,并且带有很强的人群隔裂特征 微信h5页面做登录怎么办呢?网页的登录方式会出一个二维码,仍不能直接调出微信点击确定的方式。 普通网页指的是 普通手机网页 还是 pc端的普通页面?

---以下是小菜鸟工作遇到的小坑---
普通手机内置浏览器VS微信
1.给的设计稿 viewport 直接定成了640 ,不能缩放。在微信里显示正常[微信自动把页面缩放到完整显示],但是内置的手机浏览器显示就有问题,特别是iPhone系 因为 像素的关系,页面宽度超过了屏幕的可视。
2. 安卓内置浏览器 input type=number 或者 number 时,placeholder无效

PC端页面 vs 微信
1.pc端select框由于不能变更样式,所以有采用div模拟的情况[俺们家设计师喜欢用,漂亮嘛]
但是手机页面,老老实实用select吧[可以简单更换样式,只要不太花哨就ok]。不然调用不起手机的select框。
2.比较多考虑 图片加载和低速情况,特别是低速情况。 有这些接口可以使用mp.weixin.qq.com/s?
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to run the h5 project How to run the h5 project Apr 06, 2025 pm 12:21 PM

Running the H5 project requires the following steps: installing necessary tools such as web server, Node.js, development tools, etc. Build a development environment, create project folders, initialize projects, and write code. Start the development server and run the command using the command line. Preview the project in your browser and enter the development server URL. Publish projects, optimize code, deploy projects, and set up web server configuration.

What exactly does H5 page production mean? What exactly does H5 page production mean? Apr 06, 2025 am 07:18 AM

H5 page production refers to the creation of cross-platform compatible web pages using technologies such as HTML5, CSS3 and JavaScript. Its core lies in the browser's parsing code, rendering structure, style and interactive functions. Common technologies include animation effects, responsive design, and data interaction. To avoid errors, developers should be debugged; performance optimization and best practices include image format optimization, request reduction and code specifications, etc. to improve loading speed and code quality.

What application scenarios are suitable for H5 page production What application scenarios are suitable for H5 page production Apr 05, 2025 pm 11:36 PM

H5 (HTML5) is suitable for lightweight applications, such as marketing campaign pages, product display pages and corporate promotion micro-websites. Its advantages lie in cross-platformity and rich interactivity, but its limitations lie in complex interactions and animations, local resource access and offline capabilities.

How to make h5 click icon How to make h5 click icon Apr 06, 2025 pm 12:15 PM

The steps to create an H5 click icon include: preparing a square source image in the image editing software. Add interactivity in the H5 editor and set the click event. Create a hotspot that covers the entire icon. Set the action of click events, such as jumping to the page or triggering animation. Export H5 documents as HTML, CSS, and JavaScript files. Deploy the exported files to a website or other platform.

What is the H5 programming language? What is the H5 programming language? Apr 03, 2025 am 12:16 AM

H5 is not a standalone programming language, but a collection of HTML5, CSS3 and JavaScript for building modern web applications. 1. HTML5 defines the web page structure and content, and provides new tags and APIs. 2. CSS3 controls style and layout, and introduces new features such as animation. 3. JavaScript implements dynamic interaction and enhances functions through DOM operations and asynchronous requests.

How do I handle user location privacy and permissions with the Geolocation API? How do I handle user location privacy and permissions with the Geolocation API? Mar 18, 2025 pm 02:16 PM

The article discusses managing user location privacy and permissions using the Geolocation API, emphasizing best practices for requesting permissions, ensuring data security, and complying with privacy laws.

The difference between H5 and mini-programs and APPs The difference between H5 and mini-programs and APPs Apr 06, 2025 am 10:42 AM

H5. The main difference between mini programs and APP is: technical architecture: H5 is based on web technology, and mini programs and APP are independent applications. Experience and functions: H5 is light and easy to use, with limited functions; mini programs are lightweight and have good interactiveness; APPs are powerful and have smooth experience. Compatibility: H5 is cross-platform compatible, applets and APPs are restricted by the platform. Development cost: H5 has low development cost, medium mini programs, and highest APP. Applicable scenarios: H5 is suitable for information display, applets are suitable for lightweight applications, and APPs are suitable for complex functions.

Is H5 page production a front-end development? Is H5 page production a front-end development? Apr 05, 2025 pm 11:42 PM

Yes, H5 page production is an important implementation method for front-end development, involving core technologies such as HTML, CSS and JavaScript. Developers build dynamic and powerful H5 pages by cleverly combining these technologies, such as using the <canvas> tag to draw graphics or using JavaScript to control interaction behavior.

See all articles