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 within the console either.
Thanks!
EDIT:
console.log(window.navigator);
console.log(String(window.navigator));
console.log(JSON.stringify(window.navigator));
console.log(window.navigator.serialize());
Also tried sending all these variations over the socket to the server and logging them there.
Output is either [object Navigator]
, "{}"
, or nothing
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'});
Update!!! On OS X you can use the Safari web inspector on the iOS Simulator AND iOS 6 devices.
- First enable the Developer menu in Safari.
Next, enable remote debugging on your iOS device (or simulator).
Settings > Safari > Advanced > Web Inspector (ON)
- Go back to Safari on your device.
- 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!
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).
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
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.