iOS Safari Debug H5 page

Source: Internet
Author: User

I've done mixed development before, using Javascriptcore+oc+uiwebview.

The Safari debugging feature is really useful, and it makes it easy to pinpoint where the problem is, and how to debug it.

Open Safari Development Menu

On your Mac's safari preferences, open the development menu. To do this, see the "Development" menu displayed in the menu bar with the preferences ....

iphone Open Web Checker

The steps are: Settings, Advanced Web Inspector, Safari, and so on.

Run the App

Open the project, CMD + R run, open the Web page you want to debug.

Debug the corresponding page

Opens the URL for the device, Dev-+, Safari.

The selected page will turn blue, click and then open the following interface.

This page is very much Windows like Chrome the platform F12 . You can break points:

viewing breakpoints

View Cookies

Print a cookie or element

For example, in the title of the alert page here, enter alert(document.title); , you will see the pop-up window in the simulator

The whole is very useful, the experience of the operation Xcode is very similar, the small partners explore themselves.

For example, the new H5 page, there is a share button, click to call the native share, but found that after the click did not react, what problem? Is there a problem with native-side implementation, or is there a problem with the front-end writing?

Let's take a look. Open the Safari Web Inspector, navigate to the resource, and add a breakpoint in the share method,

Will find, and did not break, but the page directly error, look at the wrong description, share method more than one “/” , so error. When I click the Share button

You will find that you are not prompted to find the variable share . Here I need to explain:

When the error in JS, the error location of the function and the error location after the code, will not be executed, so I click to share, the hint is not found method, because the syntax of JS is incorrect, error, here can not parse out, so there is no share , testAddMethod and after the function.

So when I click on the Share button below, call share the method defined below will also prompt to find the corresponding function.

At this point, the problem has been found, as long as the front-end developers can, let him repair.

The actual problems encountered may be much more complex, can be printed through breakpoints, as well as the console to print some JS variable values, DOM operations to find problems, solve the problem. I hope we can help the little friends.

iOS Safari Debug H5 page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.