hi
i have a Problem,i want to Injet a var from nativ to my WebSolution.
Cause i want to know, when a iDevice visit the page, some buttons have to be visible...
So i tried somethink like that:. On the index.html i have JQuery Script:
$(document).ready(function(){ var htmlvar = varFromUiWebView; alert(htmlvar); }
At my xCode project: On the UIWebview Delegate: UiWebviewDidFinishload:, i have something like that:
[browser stringByEvaluatingJavaScriptFromString:@"varFromUiWebView = 1;"];
So, the result is that the script crash, because 'varFromUiWebView' is undefined. How can i fix it?
Thank you in advance Konstantin
So at this time i think it isnt possible to inject a variable from :
[theWebView stringByEvaluatingJavaScriptFromString:@"var valueFromNativ = 1"];
to the DOM of the browser Website :
example :
$(document).ready(function(){
var clientValue = valueFromNativ;
});
so a very easy workaround is to catch via userAgend the Device which visit your Page:
$(document).ready(function() {
var isMobile = navigator.userAgent.match(/(iPhone|iPod|iPad|Android)/);
if (isMobile == null) {
$('#justTablets').hide();
}
});<br>
If now somebody visit with ipad my website a <div id="justTablets">Content ...</div>
will shown, but if you are a simple desktop, laptop, it will be hidden ...
see here
http://jsfiddle.net/konstheinrich188/jASy8/