iOS Question How to get document.scripts in a WebView

xulihang

Active Member
Licensed User
I am trying to get the scripts in a webview.

The link is this: http://bbs.jiangnan.edu.cn/attachments/upload.php

I want to upload some image and get the returned value like "[pic xxxx.jpg]". The value is in the script.

So I use this code to get this:
B4X:
Sub uploadWV_PageFinished (Success As Boolean, Url As String)
    Dim result As String
    Dim no As NativeObject = uploadWV
    result=no.RunMethod("stringByEvaluatingJavaScriptFromString:",Array("document.scripts[0]")).AsString  
    If result.Contains("pic") Then
        Dim ubound As Int
        Dim lbound As Int
        ubound=result.IndexOf("[pic")
        lbound=result.IndexOf("</script>")
        result=result.SubString2(ubound,lbound)
    End If
    Log(result)
End Sub
But I failed to get the result.
 
Last edited:

xulihang

Active Member
Licensed User
I solved it. I should use "document.documentElement.innerHTML" instead of "document.script[0]".

Sorry for my poor knowledge in web development.
 
Last edited:
Top