I have a problem in iOS 8 and UIWebView. I'm running an app into webview, in this app I have an icon to call the specific url. This is url that is registered like a application url (url scheme). Then into my UIWebView, when I press the button, other view controller should be shown.
In iOS 7 the button works fine, I tap on it and my other view controller is open. But in iOS 8 when I tap on the button nothing is happening. My method to handle url actions is never called.
The web page is using "window.location.href = MyUrlScheme://...", again this is working perfectly in iOS7, but not in iOS8.
Any ideas?
You've probably found the answer to this question, but I'll leave here my solution, it may help someone. I ran into this problem today, iOS8 UIWebView does not respond to window.location.href = "MyUrlScheme://do-something"...
So I added an Iframe to the html page, set the src attribute and removed the Iframe.
var sendObjectMessage = function(parameters) {
var iframe = document.createElement('iframe');
iframe.setAttribute('src', "MyUrlScheme://"+parameters);
document.documentElement.appendChild(iframe);
iframe.parentNode.removeChild(iframe);
iframe = null;
}
sendObjectMessage("send-something");
Take a look at this link https://gist.github.com/irace/3688560
Related
I've got a webview that changes it's content when a button is pressed inside the webview. Is it possible to detect if webview has changed its content in XCUITest.
Edit: I would like a general way to know if the webview has updated without having to know the content the webview will update to–prior to the update.
Sure !
You can get your webview doing something like this:
let webview = app.webviews.firstMatch
Then, you can do some assertions on the webview content:
webview.staticTexts["TestString"].firstMatch.exists
Need help on ios webview
I am trying to autofill a form located on any website can get path by ID or Xpath.
same with button want to know how to autotap send button after filling a form located on any website can get buttons xpath/ID
In selenium it was simple and easy dont know how to dive into webview looked everywhere
You use the javascript bridge to perform operations on elements using js. For example to tap on a button:
let jsString = "document.getElementById('myButtonID').click()"
myWebView.evaluateJavaScript(jsString, completionHandler: { result,error in
print(result);
})
When I am loading a URL in WebView for Android Lollipop 5.0, it shows a popup to choose a browser instead of showing the content in WebView itself. The same code was working fine in all earlier versions. What might be causing this?
Any help will appreciate.
this works for me
WebView webView = (WebView) findViewById(R.id.webLink);
webView.setWebViewClient(new WebViewClient());
webView.loadUrl(url);
We can use UIWEBVIEW to create a loading mechanism for viewing a pdf file when called in our app and we have successfully put in a 'close' or 'done' button that allows us to exit the pdf and return to the app. Our app is a website compiled using Xcode 5.1.
PROBLEM: Our 'close' / 'done' button appears on every page of our website app rather than only when the pdf is loaded. What we want is for the button to only appear when the pdf is loaded and when pressed, we can return to the app and the button disappears.
Any help very very much appreciated.
You can hide close and done button in other view like this
[closeBtn setHidden:YES];
[doneBtn setHidden:YES];
Make sure your other class able to access these buttons
if YOu Use PHONEGAP, you must use AppInBrowser
you can code like this
a href="javascript:void(0)" onclick="open_pdf('your.pdf');"
function open_pdf(url)
{ var ref = window.open(url, '_blank', 'location=no'); }
Follow :
Here's a link! And a reference-style link to [a panda][1].
this looks very simple, but I just can't figure out what's going wrong. So what I want to do is I have a button on the 1st controller, and when the user clicks that button, I push another controller into the navigation stack and show a website in the webview.
code to push the webview controller:
SellerViewController *sellerController = [[SellerViewController alloc] initWithNibName:#"SellerViewController" bundle:nil];
[self.navigationController pushViewController:sellerController animated:YES];
code to load website
- (void)viewDidLoad
{
[super viewDidLoad];
[self.sellerWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.clickUrl]]];
}
I have a UIWebView in IB and I connect it to the outlet sellerWebView. I also checked the clickUrl, it is correct.The problem is when I click the button, the new controller shows up, but no content is loaded in the webview. Any suggestions? Thanks!
As others suggested, set a delegate and check for failure.
If your request does load and your issue is with the UIWebView's content, you can debug it, see this answer.
tl;dr:
If you're using iOS >= 6 and you have mountain lion (10.8) or Safari >= 6, you can just:
Open the application in the simulator (or your device in XCode >= 4.5.x).
Open Safari (go to Preferences -> Advanced and make sure "Show Develop Menu in Menubar" is on.
From the Menu-bar (of Safari) select Develop -> iPhone Simulator -> [your webview page].
That's it !
Edit:
Glad you found the issue. You could use Safari to catch errors having to do with invalid or wrong URLs.
One you have attached the Web Inspector to your web view, click "Inspect" on the top bar, then click "Timelines" and "Network Requests", and try to load your request.
Since you left out the http:// before the path, it would likely get prefixed with file:// instead -- you'd be able to see that it is requesting the wrong resource without guesswork.