javascript - In iOS UIWebView how to get html DOM content before it finished loading? -


i getting url , i'd present in uiwebview this:

request = [nsurlrequest requestwithurl:[nsurl urlwithstring:url]]; [_webview loadrequest:request]; 

but due network restriction in china, cannot access google services page url using:

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> 

so have wait long time expire since not able js file ajax.googleapis.com, i'd exchange script source local js file in order enable javascript calls in future.

i think if can dom before finished loading, can add script source this:

<script src="//code.jquery.com/jquery-1.11.3.min.js"></script> 

but how can that?

i tried load local html file params dynamic server side.

i tried call [_webview stringbyevaluatingjavascriptfromstring:url] in uiwebview delegate methods didn't work.

my solution/workaround is:

set timer after sending url timer wait try detect received dom check if <head> has been received once while.

during timer running, received dom content may not intact until dom receiving finishes loading.

but that's ok, since want inject js code <head> first part of dom content.

so after injected <script src="//code.jquery.com/jquery-1.11.3.min.js"></script> <head> in dom, won't care when whole thing finishes loading, if clicked button on page, use jquery code injected in <head> instead of default one.

anyone has better idea, please let me know, thanks.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -