search
HomeWeb Front-endH5 Tutorial在微信上做 HTML5 网页和普通的网页开发有何不同?

回复内容:

如果考虑的范围只是微信内置浏览器和手机上的浏览器应用(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
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
Mastering Microdata: A Step-by-Step Guide for HTML5Mastering Microdata: A Step-by-Step Guide for HTML5May 14, 2025 am 12:07 AM

MicrodatainHTML5enhancesSEOanduserexperiencebyprovidingstructureddatatosearchengines.1)Useitemscope,itemtype,anditempropattributestomarkupcontentlikeproductsorevents.2)TestmicrodatawithtoolslikeGoogle'sStructuredDataTestingTool.3)ConsiderusingJSON-LD

What's New in HTML5 Forms? Exploring the New Input TypesWhat's New in HTML5 Forms? Exploring the New Input TypesMay 13, 2025 pm 03:45 PM

HTML5introducesnewinputtypesthatenhanceuserexperience,simplifydevelopment,andimproveaccessibility.1)automaticallyvalidatesemailformat.2)optimizesformobilewithanumerickeypad.3)andsimplifydateandtimeinputs,reducingtheneedforcustomsolutions.

Understanding H5: The Meaning and SignificanceUnderstanding H5: The Meaning and SignificanceMay 11, 2025 am 12:19 AM

H5 is HTML5, the fifth version of HTML. HTML5 improves the expressiveness and interactivity of web pages, introduces new features such as semantic tags, multimedia support, offline storage and Canvas drawing, and promotes the development of Web technology.

H5: Accessibility and Web Standards ComplianceH5: Accessibility and Web Standards ComplianceMay 10, 2025 am 12:21 AM

Accessibility and compliance with network standards are essential to the website. 1) Accessibility ensures that all users have equal access to the website, 2) Network standards follow to improve accessibility and consistency of the website, 3) Accessibility requires the use of semantic HTML, keyboard navigation, color contrast and alternative text, 4) Following these principles is not only a moral and legal requirement, but also amplifying user base.

What is the H5 tag in HTML?What is the H5 tag in HTML?May 09, 2025 am 12:11 AM

The H5 tag in HTML is a fifth-level title that is used to tag smaller titles or sub-titles. 1) The H5 tag helps refine content hierarchy and improve readability and SEO. 2) Combined with CSS, you can customize the style to enhance the visual effect. 3) Use H5 tags reasonably to avoid abuse and ensure the logical content structure.

H5 Code: A Beginner's Guide to Web StructureH5 Code: A Beginner's Guide to Web StructureMay 08, 2025 am 12:15 AM

The methods of building a website in HTML5 include: 1. Use semantic tags to define the web page structure, such as, , etc.; 2. Embed multimedia content, use and tags; 3. Apply advanced functions such as form verification and local storage. Through these steps, you can create a modern web page with clear structure and rich features.

H5 Code Structure: Organizing Content for ReadabilityH5 Code Structure: Organizing Content for ReadabilityMay 07, 2025 am 12:06 AM

A reasonable H5 code structure allows the page to stand out among a lot of content. 1) Use semantic labels such as, etc. to organize content to make the structure clear. 2) Control the rendering effect of pages on different devices through CSS layout such as Flexbox or Grid. 3) Implement responsive design to ensure that the page adapts to different screen sizes.

H5 vs. Older HTML Versions: A ComparisonH5 vs. Older HTML Versions: A ComparisonMay 06, 2025 am 12:09 AM

The main differences between HTML5 (H5) and older versions of HTML include: 1) H5 introduces semantic tags, 2) supports multimedia content, and 3) provides offline storage functions. H5 enhances the functionality and expressiveness of web pages through new tags and APIs, such as and tags, improving user experience and SEO effects, but need to pay attention to compatibility issues.

See all articles

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools