Questions tagged [stringbyevaluatingjavascr]

32 questions
24
votes
3 answers

WkWebView Evaluatejavascript returns unsupported type error

I'm sending a value to javascript function and get a result. However, I'm getting "Error Domain=WKErrorDomain Code=5 "JavaScript execution returned a result of an unsupported type" UserInfo={NSLocalizedDescription=JavaScript execution returned a…
Emre Önder
  • 2,408
  • 2
  • 23
  • 73
5
votes
2 answers

Loading large HTML string into UIWebView using javascript

Usually, when I want to load an HTML string into a webview using javascript, I use something like this... NSString *htmlString = @"HTML String"; [webView stringByEvaluatingJavaScriptFromString:[NSString…
3
votes
1 answer

How do I relate a UIWebView javascript exception's sourceId to a source file?

Short question: What does an exception's "sourceID" refer to, and how can I link it to the relevant source string/file? Longer story: I am running Javascript code in an iPhone native app through [UIWebView stringByEvaluatingJavaScriptFromString:].…
squelart
  • 11,261
  • 3
  • 39
  • 43
2
votes
1 answer

iOS - play embedded YouTube video using Javascript

I hope this is possible. I've embedded a YouTube video within a UIWebView in my app. I am using the stringByEvaluatingJavaScriptFromString approach for using javascript. I want to press a button in the app and make the YouTube video start playing. …
Romes
  • 3,088
  • 5
  • 37
  • 52
1
vote
1 answer

Passing a UISlider value into stringByEvaluatingJavaScriptFromString?

I have a UISlider and I'm trying to pass its value into a window.scrollBy string. Basically, I'm attempting user-configurable auto-scrolling of web content. The actual scrolling is working, but I'm unable to pass a value into the JavaScript by using…
Luke
  • 9,512
  • 15
  • 82
  • 146
1
vote
3 answers

load local image into UIWebView

I want to take a screenshot and then send to webview a local path for it, so it will show it. I know that webview could take images from NSBundle but this screenshots are created dynamically - can I add something to it by code? I was trying it like…
Piotr
  • 1,743
  • 1
  • 26
  • 40
1
vote
1 answer

Horrible performance when removing HTML element from UIWebView

I'm currently writing an iOS app that uses a UIWebView for surfing around pages. Sometimes I need to dynamically remove elements in the UIWebView using stringByEvaluatingJavaScriptFromString:, but this locks up the main UI for sometimes up to 2…
Erik Rothoff
  • 4,826
  • 9
  • 41
  • 59
1
vote
1 answer

stringByEvaluatingJavaScript object has no ID

I am using self.webView.stringByEvaluatingJavaScript(from: "document.getElementById('username').value = \"\(username)\"") to put in a username, and it works fine. A different webpage has this field:
ZiEiTiA
  • 275
  • 2
  • 16
1
vote
0 answers

JavaScript exception for element height in WKWebView - Objective-C

I have following HTML structure to load in WKWebView : ... //CSS code ...
... //Actual contents to display ...
... //Javascript code ... I'm loading above HTML as…
iAkshay
  • 1,143
  • 1
  • 13
  • 35
1
vote
0 answers

Calling javascript method from objective-C

I am working on calling javascript function from objective C. I have a function like this: var ABC = { testingFunctionA : function() { alert("Testing ABC!"); return "Hi"; }, testingFunctionB : function() { …
1
vote
1 answer

How to display a JavaScript alert dialog in UIWebView using stringByEvaluatingJavaScriptFromString but not performSelectorOnMainThread in Swift?

In Objective-C, the following code works in viewDidLoad: [self.myWebView performSelectorOnMainThread: @selector(stringByEvaluatingJavaScriptFromString:) withObject:@"alert('Test')" waitUntilDone:NO]; This code is suggested by this: UIWebView…
1
vote
0 answers

Swift - stringByEvaluatingJavaScriptFromString - Upload image

Inside my application I give the user access to UIImagePickerController allowing them to either take a photo or choose from the library to save to a path in the DocumentDirectory: //Obtaining Saving Path let path:NSArray =…
1
vote
2 answers

Is it possible to use stringByEvaluatingJavaScriptFromString with Javascript which references local files?

I want to use stringByEvaluatingJavaScriptFromString to run a javascript which references local files (in this case css files, but potentially js files too) which are on the device (in the Documents folder I guess?)... NSString *theJS = [[NSString…
cannyboy
  • 24,180
  • 40
  • 146
  • 252
1
vote
0 answers

Force A UIWebView Page to Press A Link?

Hello I have wrote an app that gets recent player information from xbox live and shows the players you are playing with in a game! I am trying to improve the app by having no need for the user to be on the web page and just gets the list of recent…
Charlie
  • 222
  • 3
  • 20
1
vote
1 answer

iOS stringByEvaluatingJavaScriptFromString issue

I have this code below that setup my UIWebView: - (void)webViewDidFinishLoad:(UIWebView *)webView { [webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"document.getElementById(\"image\").src=\"q%@.png\";",…
Matrosov Oleksandr
  • 25,505
  • 44
  • 151
  • 277
1
2 3