I have an android activity with WebView in it. When the activity loads with a page, it has two buttons (in html) one for accept and one for decline.
When the user clicks accept, the application works the way it should.
What I want is when a user clicks the decline button, the application should go to the previous activity. Since this is a webview so it has to be done through javascript. I have already tested running javascript and can execute toast messages from webpage.
I want an exact line which I should write to close the activity, or go back.
Secondly, can I track the URLs which web view is going to, as Once the job of webview is done, and it goes to a specific page, and from there I want to return to my application, how can this be done?
Best way to do that is to make redirect call from your javascript code to the specified url, which will be parsed by your custom WebView, so you will be able to handle this redirect from your WebView code and finish your Activity or something else
Related
I'm working with asp.net ASPX pages. I've put toastr.js on my MasterPage. It works properly. I'm using it on a page with a Save button that stays on the same page like so:
ScriptManager.RegisterStartupScript(this, this.GetType(), "toastr", "toastr.info("Save successful.");", true);
and a Save&Continue button that saves and loads the next page like so:
ScriptManager.RegisterStartupScript(this, this.GetType(), "toastr", "toastr.info("Save successful.");window.location='NextPage.aspx';", true);
But, when I click the Save&Continue button it flashes the notification but then the next page loads and it's gone. No persistence across changing pages.
Maybe I'm fuzzy on javascript specifics but is there some asynchronous way to load the toast notifications so they aren't specific to a page?
I don't know much about ASP.NET WebForms, but here are some things to consider:
The issue is that when you submit and process a form using server side code (C# in this case), the entire page reloads, including your javascript files. This is why the toastr disappears when you click Save&Continue.
The only thing that I can think of would be this:
The method that runs when you click Save&Continue, would need to pass the necessary information to the next page, so that page two would know to display the toastr instead of page1.
If you truly want to submit a record to the database, navigate away and have a toastr displaying the entire time, you may want to look into Single page applications (Allowing you to make asynchronous requests, with routing, while staying on the same page, allowing the JS to keep running without full page refreshes). Although this could mean rewriting your application, which might not be an option.
I have an HTML5 application that manipulates the browser history to show the proper URL for Ajax calls. This works great, but a problem occurs when my application has hyperlink to an external site, say http://www.google.com. When this happens, the history looks like this:
My App Page A -> My App Page B -> Google
When the user hits the back button once, everything is fine. My App Page B is shown.
But when the user hits the back button a second time, the URL changes, but the page doesn't change. My app can't make the proper Ajax call to show the state for My App Page A, because the onpopstate handler never got called. This is because the handler wasn't initialized when the browser went back to My App Page B (no events fire on that back event, so I can't reinitialize the handler.)
This experience is with Chrome, but I have no reason to believe it is Chrome-specific. Is there a way around this problem?
I know that applications like Gmail open all external hyperlinks in a new window. But the requirements for my application don't allow me to do that.
The link provided by #Pumbaa80 put me on track to the right answer.
If you put <body onunload=""> on your page, then is breaks the bfcache on Chrome and other browsers. This means that when you click the back button to return to My App Page B from Google, all page state JavaScript events will fire.
There is no way to get onpopstate to get called on My App Page B after coming back from Google. (This woud be illogical, as that event only fires on the page where you hit the back button.)
The alternative is to execute the logic when My App Page B loads. By breaking the bfcache as described above, jQuery dom ready will fire. By running similar code from onpopstate in a jQuery dom ready callback, I can access the data stored in the History object reset the state of my HTML5 web app after returning from an external page.
I think you'll need to use hash tags to save the state of your page, I don't see a way around this. I've done it in the past with great success using this jQuery plugin, with the very fashionable name BBQ (Back Button & Query library). This will allow your page to perform actions based on the hash tags in the URL.
I want to make a mobile app that makes a user like a certain page to continue.
I know that to check if a user has liked a page for a regular app you can make the app a tab of that page, and then use the signed_request to see if the user has like the page.
How would this work in mobile? I have looked to see if you can include a mobile page as a tab, but I couldn't find much information.
Can you include a mobile app as a tab? If not then how would you make a user like a page before entering?
I will be using jquery mobile and javascript for most of the non back end work.
try this
You can subscribe to events . Following event will be raised when some user clicks "Like" button.
FB.Event.subscribe('edge.create', function(response) {
//redirect or perform some action
});
Source : http://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/
I would like to have my web app be abple to pop open new windows like GMail does for chats and phone calls but I'd also like to be able to detect if they click on something in the nav that will take the main window to another URL and break the code running in the popups windows.
Ideally it would prompt them and give them a chance to cancel the page change and not break the app. Any ideas how GMail does this?
You want to use the onbeforeunload event. The string you return will be displayed to the user in a dialog, giving the user the option of canceling the page navigation.
I'm trying to fill out two textfields and press a button programmatically that is opened in a webview in my webos app. Is there any possibility to do that? The website has to be openend in a webview because it refreshes every 30 seconds. (I wan't to log me in automatically to our university's homepage.)
I doubt you will be able to script the contents of the WebView directly (too many potential security issues at stake).
However, you might be able to simulate a Javascript bookmarklet by loading the page and then using the WebView's openURL method to run a bookmarklet that fills out the fields and submits the form (so something like myWebView.mojo.openURL('javascript:DO_STUFF_HERE') might work). I have never had a need to test this sort of thing, but that's the only way I can think of that you'd be able to execute Javascript within a WebView.
Good luck!