×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Nov 2013
    Posts
    24

    detect taps/interaction within the WebView in windows 8.1 app

    Hi All,

    I want to calculate idle time of my windows 8.1 app and perform some action after x mins of inactivity. So i have a timer running of x mins which resets whenever a onmousedown event occurs for controls on the page. This works fine for all controls but not for WebView.

    Before, when the app was targeted towards Windows 8, i was able to inject javascript into the webpage then call window.external.notify and get messages back into WebView's ScriptNotify whenever onmousedown was called on web page.

    However, after the app is re-targeted to Windows 8.1, microsoft has deprecated the APIs in Windows 8.1 to fire messages from any webpage http://msdn.microsoft.com/en-us/libr...fy.aspx#win8.1. Now we need to list the allowed URI's in ApplicationContentUriRules section of the app manifest that too with https protocol only. For me its not feasible to list all domains. user can browse through any domain.

    So do we have some work around or solution for this issue.?

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,572

    Re: detect taps/interaction within the WebView in windows 8.1 app

    So far Nokia does not manufacture devices running desktop Windows, so these questions are considered off-topic on this site.

  3. #3
    Registered User
    Join Date
    Nov 2013
    Posts
    24

    Re: detect taps/interaction within the WebView in windows 8.1 app

    Hi Wizard,
    Quote Originally Posted by wizard_hu_ View Post
    So far Nokia does not manufacture devices running desktop Windows, so these questions are considered off-topic on this site.
    Yes i know but since winRT and WinPhone has lot of stuff in common and this community is dedicated to WinPhone(asha too), so just in case if someone knows.

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,572

    Re: detect taps/interaction within the WebView in windows 8.1 app

    Anyway, as the question had very little chances to get attention in the general board, it is moved to the WP boards now.

  5. #5
    Regular Contributor
    Join Date
    Dec 2012
    Posts
    66

    Re: detect taps/interaction within the WebView in windows 8.1 app

    Hi Nikita,

    What you need to do is

    Inject a onmousedown event script in the webpage and on invoke of that event redirect you page to a unique url

    Code:
    private static string MouseDownScript_81 = @"
    document.body.nomousedown = function()
    {
        window.location.href = 'http://www.myveryuniquewebsiteurl123456789kd875yjfjwer484oekedhysdw7y3ojd.com/?action=webViewTapped';
    }";
    
    myWebView.InvokeScript("eval", new string[] { MouseDownScript_81 });
    After the WebView starts navigation your WebView's NavigationStarting handler will get called. There you can check if the navigation url is your unique url and take your required actions.
    Code:
    void Webview_NavigationStarting(WebView sender, WebViewNavigationStartingEventArgs args)
    {
    	if (args.Uri.AbsoluteUri.Equals("http://www.myveryuniquewebsiteurl123456789kd875yjfjwer484oekedhysdw7y3ojd.com/?action=webViewTapped", StringComparison.CurrentCultureIgnoreCase))
    	{
    		//your special actions here
    		return;
    	}
    
    	//usual navigation handling code
    }
    Regards,
    Vinay

  6. #6
    Registered User
    Join Date
    Nov 2013
    Posts
    24

    Re: detect taps/interaction within the WebView in windows 8.1 app

    Great trick Vinay,

    Works like charm. Can be used with alert, new window and other events too.

    Thanks

Similar Threads

  1. Replies: 3
    Last Post: 2012-04-26, 14:14
  2. QML webview
    By ENEX in forum [Archived] Qt Quick
    Replies: 2
    Last Post: 2011-05-06, 06:35
  3. Multi page form or multi taps
    By zohirey2 in forum Symbian User Interface
    Replies: 2
    Last Post: 2009-06-04, 11:57
  4. PC suite can't detect my 6680 phone althouth PC detect it
    By Elnegm in forum PC Suite API and PC Connectivity SDK
    Replies: 1
    Last Post: 2006-12-25, 18:39
  5. Connection Manager cannot detect devices after Windows reboot
    By RESTELLI in forum PC Suite API and PC Connectivity SDK
    Replies: 0
    Last Post: 2005-08-18, 11:53

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •