iOS Question How to get document.scripts in a WebView

Discussion in 'iOS Questions' started by xulihang, Feb 11, 2015.

  1. xulihang

    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:
    Code:
    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: Feb 11, 2015
  2. xulihang

    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: Feb 11, 2015
    Erel likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice