How to trace all javascript events on page (mobile browser)? - javascript

Is there a way to get a log of all events that are generated on a given page? Printing events' names to console for example would be enough.
The reason is to know what happens on a particular user action (http://stackoverflow.com/questions/10071397/is-there-a-way-to-see-that-a-browser-window-is-minimized-while-the-user-is-switc).

If you're debugging Mobile Safari, run iOS >= 5.0 in the iOS Simulator and run iWebInspector. In the Timeline tab you should be able to see every event being fired by the browser after pressing the record button.

if you are using google chrome then you can connect your mobile device to your system using USB and in the google chrome try opening
chrome://inspect/#devices url.
Under Remote Target, the sites you opened in your mobile browser will be listed. You can click inspect to debug the site.
In the console use Monitor Events to track all the events.
for more info, you can check the Remote debug Android devices

Related

Where to look into for the Safari browser error console in IPad which is using IOS 7?

I have an application which is running on Safari in IPad(IOS 7) . When i click on one of the button it is showing some JS error. Where exactly i need to into for the script error console? I don't see any error console in safari when it is running on IPad.
Get a Mac computer
Open Safari on Mac
Enable the Develop menu https://developer.apple.com/library/mac/documentation/AppleApplications/Conceptual/Safari_Developer_Guide/GettingStarted/GettingStarted.html
Using a cable, connect your iPad to the Mac
On the iPad enable Web Inspector. Settings > Safari > Advanced (scroll down to the bottom to see it) > Web Inspector (set to On)
On the iPad open the Web application
On the Mac open the Develop menu. When it drops down, you will see your iPad shown in the menu as a separate menu item. That menu item should have a submenu showing Web pages/applications currently opened on your iPad. Choose your Web application.
You get your application in the Development Console, so do whatever you can (Safari Development tools are pretty weird, but, still, better something than nothing :) )
Actually you can see the console on Mac's Safari when your iPad is connected to it.

How can I force my webpage to open in iOS Safari instead of an in-app UIWebView?

The in-app UIWebView is limited in iOS. If I'm seeking to take advantage of features inaccessible by UIWebView on my website, how can I force a link to open a page in iOS Safari instead?
For example, assume my web page includes the following:
Open in Safari
If someone is browsing this page in another app (let's say Google Chrome or Twitter for iOS), how can I force Safari to open this link instead?
Here's a JSFiddle to demonstrate the native behavior, and communicate the desired behavior:
http://jsfiddle.net/gXLjF/
Open this from iOS Google Chrome (or any other non-Safari iOS browser) to see for yourself:
http://jsfiddle.net/gXLjF/embedded/result/
I've seen many questions here from the app developer's perspective, but how about from the web site's perspective. Is there a proper target attribute to trigger this action? Or a JavaScript function to force this behavior?

Set focus on web page rather than Firefox debugger after refreshing page

I'm using the default Firefox web developer tools. Firefox 20.0, Mac OS X 10.7.
If I have the developer tools' Debugger panel open (but not focused), and refresh the page, focus goes to the debugger panel rather than the refreshed page. Can I set focus to go to the refreshed page instead?
If I have the Web Console panel open instead, that doesn't steal the focus - ideally I'd like to get the debugger to behave the same way.
My program uses document keyup and keydown events, and the page needs focus for these to work. Having to click on the page each time is proving surprisingly annoying (it's only a small thing, but it's doubling the amount of work required for each refresh!).
This is still an annoyance, as of Firefox 61.0.2 (Windows 7).
The only workaround I've found is to have Developer Tools set to run in "Separate window" mode - instead of docked to the browser, like:
use this on page
<body onload = "window.focus();">

Device Motion API on android should work

For some reason, when using a Galaxy S3, I'm able to use the example demo from HTML5Rocks about Device Motion and get acceleration values from the phone's hardware.
Demo: http://www.html5rocks.com/en/tutorials/device/orientation/devicemotionsample.html
But I can't seem to get the code working on my own website. It should just be:
if((window.DeviceMotionEvent)||('listenForDeviceMovement'in window))
{window.addEventListener('devicemotion',deviceMotionHandler3,false);
function deviceMotionHandler3(eventData){var
acceleration=eventData.accelerationIncludingGravity;
...
Any ideas why this code would work for the website above, but not when I copy it into a blank html page?
Are you sure the device you're testing on supports detecting device motion?
Are you accessing the web page from a mobile device browser?
When I click on the link you provide from my PC I'm told that the device doesn't support the device motion event.

iPad - window.open("tel:555", "_top") is not invoking default behavior

I'm developing an mobile site and need to invoke a phone call on mobile at the touchend event. On iPhone and Android the window.open('tel:555', '_top') is working fine, invoking a phone call.
On iPad, the default behavior is to offer a "Add to contacts" or "Copy" option. When using a link, it's working fine, as in <a href='tel:555'>555</a>
When trying window.open('tel:555', '_top') on iPad I'm getting:
Cannot Open Page
Safari cannot open the page because the address is invalid.
I've also tried setTimeout('window.location="tel:555";', 500); from How to trigger click-to-call with javascript (iphone), same problem.
Is there a way to invoke the default behavior with Javascript?
I believe this is the correct behaviour.
In the Apple URL Scheme Reference they specifically say that...
If the Phone application is not installed on the device, opening a tel URL displays an appropriate warning message to the user.
I would assume that an iPod Touch would also produce a similar error.

Categories

Resources