my app is creating html file from a string and inject it into my UIWebview using loadData.
my assets (images and js files) are downloaded from remote server into my device, and i give their baseUrl into the loadData method (documents/pics/assets).
in this directory i also have 2 files of jquery.
my problem is that the uiwebview can not use the jquery, i don't know why. my html finds the other assets in the same dir (images) but it seems it can't find the jquery.
when i try using it on the regular safari, it works. when inserting the js code into the html file, it works. but using the files localy not working on my ipad.
this is my code in app:
NSArray *docDir = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *imagePath = [NSString stringWithFormat:@"%@/pics", [docDir objectAtIndex:0]];
NSString *imagePath = [NSString stringWithFormat:@"%@/pics", [docDir objectAtIndex:0]];
imagePath = [imagePath stringByReplacingOccurrencesOfString:@"/" withString:@"//"];
imagePath = [imagePath stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
NSData *htmlDataPortrait = [_stringFromData dataUsingEncoding:NSUnicodeStringEncoding allowLossyConversion:YES];
[_portraitWebview loadData:htmlDataPortrait MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:[NSURL URLWithString: [NSString stringWithFormat:@"file:/%@//",imagePath]]];
and this is the code i'm trying to use in my html file:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 1024px;
margin-bottom: 606px;
background-repeat: no-repeat;
background-color: transparent;
}
</style>
<script type="text/javascript" src="assets/jquery.min.js"></script>
<script type="text/javascript" src="assets/func.js"></script>
<script>
$('body').ready(function(){
reOrderArtWithImgOpt('1');
$('div#fullpage').css('visibility', 'visible');
imgNum = $('img[width!=0]').length;
imgIndex = 0;
$('img').load(function(){
++imgIndex;
if (imgIndex == imgNum) {
setTimeout("setEventDone()", 50);
}
});
});
function setEventDone(){
window.location.href = 'myapp://loaded';
}
</script>
<script type="text/javascript">
touchMove = function(event){
// Prevent scrolling on this element
event.preventDefault();
}
</script>
the "assets/..." dir is in the documents/pics dir.
the code is not entering:
$('body').ready(function(){
thanks.