Display a child URL with a parent URL in the back history of WKWebView in iOS - ios

I want to display a new WKWebView instance, such that the page currently displayed to user is the childURL, but another URL, parentURL, is in the back history of the WKWebview, such that if the user goes back in history (through a gesture or through a button which calls WKWebView's goBack function) then parentURL will be displayed.
Imagine loading parentURL at first in the webview, then tapping a link that goes to childURL. I want this (childURL is displayed, parentURL in the back history) to be my initial state in the WKWebView.
How can I do this?

I suggest:
A WKWebView displays your childURL in the beginning.
When tapping the go back button, the WKWebView make a new request of the parentURL. The button should be a native iOS UIButton. After tapped the go-back-button, change its action to make the WKWebView not to request the parentURL again.
If the go-back-button is in the .html, try to interact with javascript.
If there is some other problems left, talk to me.
If your urls is different .htmls, I think it is simple to do what i say. Your go back is just go to a new url actually.

Related

How to navigate to different page while coming back from activity in WL.NativePage.show()?

My scenario is this: I am using WL.NativePage.show(nativePageClassName, backFromNativePage, params) to navigate to an activity. Once returning back to the WebView, I need to navigate directly to other page(Div) in html, rather from the page I originally navigated from to the activity, which is developed using jQuery-Mobile.
See the below example code.
WL.NativePage.show("com.example.SignatureActivity", function(data) {
if(data.goToPage == "example2"){
$.mobile.changePage('#example2-page',{transition: 'none'});
}else{
$.mobile.changePage('#example1-page',{transition: 'none'});
}
});
Here I am using WL.NativePage.show() In example1-page, I have two buttons in activity, one is save and one is back, while saving I need to navigate to example2 and while back, its example1.
I am able to navigate to example2, but example1-page is executing and displaying first and then displaying example2-page.
Please give me suggestions on how to navigate directly to example2-page without displaying example1-page.
You can't navigate directly from the activity to a different place in the DOM which is in the WebView from which you navigated to the activity.
What you could do, is open displaying the activity, also hide the current content in the WebView. I assume it is a DIV essentially - so you could do something with display:none or any other standard method.
That way when the user returns back to the WebView from the activity and the code to change page is executed, you could then play again with the visibility of the DIV to display it when needed.
This way what you don't want to be seen will not be shown.

How to navigate back to a Page and avoid reloading webview?

I have a Windows Phone Store app (XAML) with a Page (MainPage.xaml) that has a webview that loads content and URLs. At certain point i have to navigate to a different windows phone page (Page2.xaml), once the data there is submitted i navigate back to MainPage.xaml, but the webview control always reloads the content and user has to reenter the data again.
Is there any way to make a snapshot of the webview and load it when Navigating back to MainPage.xaml?
I have tried the NavigationHelper, but in the onNavigatingFrom event from MainPage when i try to save the Frame.Content, its the Page2 the one being passed in the NavigationEventArgs.
Any ideas?
One way to do it is to never leave the page. To do this, create two grids. One for the webview and one for the other view. When the page loads, show the first grid and hide the second grid. When you want to show the second view hide the first grid and show the second.
I have used this method in several apps on the phone and windows store and you can simulate popups this way as well.

ios webview open link in different tab/webview

I have two tabs (things that are at the bottom of the 'Clock' app) both have webviews. how can I make a link that was clicked on first tab's webview be opened (and show to user) in second tab second webview if there is a string "test" in the URL.
thnak you!
You'll need to set a delegate on your UIWebView and then handle the delegate method to be able to intercept the click and send it to the tab you want.
Here's an example: UIWebView open links in Safari

disable external url links in UIWebView

I used some open resource to handle my external links in WebView, so right now every time I click the url a new view would show the page with "Done" "back" "forward" "open link in safari" something like that. But at the same time the earlier webview of my app is still loading and show the url website. How could I stop it? When the user click Done for the new page, definitely they want to go back to the earlier page.
here is the open resource class I used : https://github.com/samvermette/SVWebViewController
Thanks. wish I made myself clear. I'm new here, and also new to ios development.
Not entirely clear what you're asking but every time a link is clicked in a UIWebView, the UIWebView delegate shouldStartLoadWithRequest method gets called.
If you don't want the link to load you simply return NO from this method.
There are also properties in the UIWebView class to enable you to go back or go forward through the page history.
If that doesn't answer your question, can you try and rephrase it.

UIWebView goBack() issues in iOS 5

I'm displaying a UIWebView to display a mobile website. The website uses ajax and internal hash navigation. I have a back button to go back in history.
It works fine on iOS 4 and on iOS for the first time after application launch.
After leaving the UIWebView and coming back to it, the back button does not work properly because of the caching.
Any ideas how we can get the back functionality/history keeping working in iOS5? We have tried several things on the web page, and natively, but no success.
Our current status is that clicking the back button will return to the initial page on the UIWebView, but jump over the intermediate pages.

Resources