How can I inspect the window object for mobile safari?

后端 未结 5 2032
南旧
南旧 2020-12-06 06:33

How can I inspect the window object for mobile safari?

Or more specifically window.navigator - trying to convert to string doesn\'t work and I can\'t explore it with

相关标签:
5条回答
  • 2020-12-06 06:38

    Update!!! On OS X you can use the Safari web inspector on the iOS Simulator AND iOS 6 devices.

    1. First enable the Developer menu in Safari.
    2. Next, enable remote debugging on your iOS device (or simulator).

      Settings > Safari > Advanced > Web Inspector (ON)
      
    3. Go back to Safari on your device.
    4. Go back to your computer, click the Developer menu, and select your device (e.g. iPhone Simulator, iPhone)

    Note: You'll see your device in the Developer menu ONLY when Safari is active and running.

    Enjoy!

    0 讨论(0)
  • 2020-12-06 06:40

    You can also use this to activate Firebug on your device. Took me a lot of time to find this.

    http://martinkool.com/post/13629963755/firebug-on-ipad-and-iphone

    0 讨论(0)
  • 2020-12-06 06:56

    Those outputs look entirely correct. E.g., when I ask for the string version of window.navigator, I correctly get

    console.log(String(window.navigator));
    "[object Navigator]"
    

    On the other hand, when I ask for a specific value, I get (in Chromium):

    console.log(window.navigator.userAgent);
    "Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.71 Safari/534.24"
    

    And when I try to enumerate all items, I get

    for (var i in window.navigator) console.log(i);
    language
    product
    mimeTypes
    appVersion
    plugins
    onLine
    platform
    vendor
    appCodeName
    cookieEnabled
    geolocation
    appName
    productSub
    userAgent
    vendorSub
    javaEnabled
    getStorageUpdates
    

    (please be aware that in the above line of code I didn't check for hasOwnProperty, which you normally should use when iterating over object elements).

    0 讨论(0)
  • 2020-12-06 07:04

    There isn't a Developer Tools window in mobile safari. There is a Debug Console, which will report errors in javascript, html and css, but it is nowhere near Developer Tools you'll find in a desktop browser. This debug console doesn't allow input of javascript (although this can be done in the address bar, eg javascript:alert("hi");)

    To enable the Debug Console, open the settings app, go to the Safari menu, then Developer, and then turn on the debug console. Go back to Safari, scroll to the top of the page and it will be obvious what to do to get to the Debug Console.

    0 讨论(0)
  • 2020-12-06 07:05

    I like jsconsole.com.

    Also, you can use the json2.js library (https://github.com/douglascrockford/JSON-js), which will give you JSON.stringify() function.

    console.log(JSON.stringify({a:'a',b:'b'});
    
    0 讨论(0)
提交回复
热议问题