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.
或者更具体地说是window.navigator - 尝试转换为字符串不起作用,我也无法在控制台中探索它。
Thanks!
谢谢!
EDIT:
编辑:
console.log(window.navigator);
的console.log(window.navigator);
console.log(String(window.navigator));
的console.log(字符串(window.navigator));
console.log(JSON.stringify(window.navigator));
的console.log(JSON.stringify(window.navigator));
console.log(window.navigator.serialize());
的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
输出是[对象导航器],“{}”或什么都没有
5 个解决方案
#1
4
I like jsconsole.com.
我喜欢jsconsole.com。
Also, you can use the json2.js library (https://github.com/douglascrockford/JSON-js), which will give you JSON.stringify() function.
此外,您可以使用json2.js库(https://github.com/douglascrockford/JSON-js),它将为您提供JSON.stringify()函数。
console.log(JSON.stringify({a:'a',b:'b'});
#2
35
Update!!! On OS X you can use the Safari web inspector on the iOS Simulator AND iOS 6 devices.
更新!在OS X上,您可以在iOS模拟器和iOS 6设备上使用Safari Web检查器。
- First enable the Developer menu in Safari.
- 首先在Safari中启用Developer菜单。
-
Next, enable remote debugging on your iOS device (or simulator).
接下来,在iOS设备(或模拟器)上启用远程调试。
Settings > Safari > Advanced > Web Inspector (ON)
- Go back to Safari on your device.
- 在设备上返回Safari。
- Go back to your computer, click the Developer menu, and select your device (e.g. iPhone Simulator, iPhone)
- 返回计算机,单击开发人员菜单,然后选择您的设备(例如iPhone模拟器,iPhone)
Note: You'll see your device in the Developer menu ONLY when Safari is active and running.
注意:只有当Safari处于活动状态且正在运行时,您才会在“开发人员”菜单中看到您的设备。
Enjoy!
请享用!
#3
1
Those outputs look entirely correct. E.g., when I ask for the string version of window.navigator
, I correctly get
这些输出看起来完全正确。例如,当我要求window.navigator的字符串版本时,我正确地得到了
console.log(String(window.navigator));
"[object Navigator]"
On the other hand, when I ask for a specific value, I get (in Chromium):
另一方面,当我要求特定值时,我得到(在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).
(请注意,在上面的代码行中,我没有检查hasOwnProperty,通常在迭代对象元素时应该使用它)。
#4
1
You can also use this to activate Firebug on your device. Took me a lot of time to find this.
您也可以使用它来激活设备上的Firebug。花了我很多时间才找到这个。
http://martinkool.com/post/13629963755/firebug-on-ipad-and-iphone
http://martinkool.com/post/13629963755/firebug-on-ipad-and-iphone
#5
0
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");
)
移动版Safari中没有“开发人员工具”窗口。有一个调试控制台,它将报告javascript,html和css中的错误,但它远不及桌面浏览器中的开发人员工具。这个调试控制台不允许输入javascript(虽然这可以在地址栏中完成,例如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.
要启用调试控制台,请打开设置应用程序,转到Safari菜单,然后打开Developer,然后打开调试控制台。返回Safari,滚动到页面顶部,显示如何进入调试控制台。
#1
4
I like jsconsole.com.
我喜欢jsconsole.com。
Also, you can use the json2.js library (https://github.com/douglascrockford/JSON-js), which will give you JSON.stringify() function.
此外,您可以使用json2.js库(https://github.com/douglascrockford/JSON-js),它将为您提供JSON.stringify()函数。
console.log(JSON.stringify({a:'a',b:'b'});
#2
35
Update!!! On OS X you can use the Safari web inspector on the iOS Simulator AND iOS 6 devices.
更新!在OS X上,您可以在iOS模拟器和iOS 6设备上使用Safari Web检查器。
- First enable the Developer menu in Safari.
- 首先在Safari中启用Developer菜单。
-
Next, enable remote debugging on your iOS device (or simulator).
接下来,在iOS设备(或模拟器)上启用远程调试。
Settings > Safari > Advanced > Web Inspector (ON)
- Go back to Safari on your device.
- 在设备上返回Safari。
- Go back to your computer, click the Developer menu, and select your device (e.g. iPhone Simulator, iPhone)
- 返回计算机,单击开发人员菜单,然后选择您的设备(例如iPhone模拟器,iPhone)
Note: You'll see your device in the Developer menu ONLY when Safari is active and running.
注意:只有当Safari处于活动状态且正在运行时,您才会在“开发人员”菜单中看到您的设备。
Enjoy!
请享用!
#3
1
Those outputs look entirely correct. E.g., when I ask for the string version of window.navigator
, I correctly get
这些输出看起来完全正确。例如,当我要求window.navigator的字符串版本时,我正确地得到了
console.log(String(window.navigator));
"[object Navigator]"
On the other hand, when I ask for a specific value, I get (in Chromium):
另一方面,当我要求特定值时,我得到(在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).
(请注意,在上面的代码行中,我没有检查hasOwnProperty,通常在迭代对象元素时应该使用它)。
#4
1
You can also use this to activate Firebug on your device. Took me a lot of time to find this.
您也可以使用它来激活设备上的Firebug。花了我很多时间才找到这个。
http://martinkool.com/post/13629963755/firebug-on-ipad-and-iphone
http://martinkool.com/post/13629963755/firebug-on-ipad-and-iphone
#5
0
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");
)
移动版Safari中没有“开发人员工具”窗口。有一个调试控制台,它将报告javascript,html和css中的错误,但它远不及桌面浏览器中的开发人员工具。这个调试控制台不允许输入javascript(虽然这可以在地址栏中完成,例如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.
要启用调试控制台,请打开设置应用程序,转到Safari菜单,然后打开Developer,然后打开调试控制台。返回Safari,滚动到页面顶部,显示如何进入调试控制台。