html - Swift - execute Javascript on each page -


i have uiwebview pass html file load.

the html file includes javascript looks existence of variable. if exists, performs 1 action, if variable doesn't exist, script performs action.

if(typeof customvar === 'undefined')   //perform task1 else   // perform task 2 using customvar 

on native, use function stringbyevaluatingjavascriptfromstring set variable before page loaded. so, i'm setting code in webviewdidstartload (i tried place in shouldstartloadwithrequest).

func webviewdidstartload(webview: uiwebview) {     let cutvar = "test"     webview.stringbyevaluatingjavascriptfromstring("customvar = '\(cutvar)';") } 

this works when load page first time, first time. after that, seems through webviewdidstartload, re-assign variable in current page, , reload page itself. means, page reloaded without variable set.

is there way want run javascript bit next page load? maybe global variable accessible?

thank you.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -