I am attempting to log into a page using a UIWebView. Due to how complicated the infrastructure is, I'm loading the login page and manually submitting the form (inserting javascript). Once the home page is loaded, I want to redirect to another page. The only problem is that there is nothing I can do to have that redirect wait until the home page is loaded (Because I didn't load the view I submitted a form). Is there a way I can get it to wait?
My code currently
webView.stringByEvaluatingJavaScriptFromString(jScript3) //submit the form
let gradeURL = NSURL(string: "https://redirectpage")!
let gradeRequest = NSMutableURLRequest(URL:gradeURL)
webView.loadRequest(gradeRequest)
Thank you!
I think u may want get something from the redirect page.
First set the Delegate and then use UIwebViewDelegate funcion
func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool {
//do nothing except 4 the redirectURL
if request.URL?.absoluteString.hasPrefix(redirectURL) == false {
return true
}
//detailly handle the query
if let _query = request.URL?.query where _query.condition {...}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.