Home > Software engineering >  How to extract value from an injectedJavaScript variable
How to extract value from an injectedJavaScript variable

Time:11-06

I am using a Webview to render a webpage and also get some info from the webpage

...
const yourAlert = `let theUrl=document.getElementById("jp_audio_0").src;`
//after getting theUrl value
console.log(theUrl)
return(
   <View style={{flex:1}}>
       <WebView>
           javaScriptEnabled={true}
           injectedJavaScript={yourAlert}
           source={{ uri:"..." }}
        />
    </View>
)

How do I access the value stored in 'theUrl'

CodePudding user response:

You can use eval function, like:

eval("my script here");

Notice: I don't recommend it at all

  • Related