tcd
tcd

Reputation: 1605

Calling App Files in my UIWebView website

I have a UIWebView app and I'm loading a website built with PHP, jQuery and Ajax. I have a few external jQuery plugin files that I call, along with some images.

EX: <script type="text/javascript" src="http://www.mydomain.com/jquery.easing.1.3.js"></script>

This makes the app load somewhat slowly... Is it possible to put the jquery.easing.1.3.js file into my "Supporting Files" folder within Xcode and then call the plugin on my website by doing something like:

<script type="text/javascript" src="file://supporting_files/jquery.easing.1.3.js"></script>

If so, what would be the extension to grab these files from my app?

EDIT (ADDITIONAL CODE):

In my PHP file:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> (along with other external files)

<script type="text/javascript">
$(document).ready(function(){   
    $('#body').fadeIn(500);
});
</script>

<body id="body>

So the page fades in when it is loaded... Obviously, this requires jQuery, and the app won't reveal the site when I try to inject jQuery...

In Xcode:

- (void)viewDidLoad
{

    [super viewDidLoad];

    //load URL into webview
    [myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL
                                URLWithString:@"http://mydomain/file.php"]]];

}

Upvotes: 0

Views: 312

Answers (1)

Ravi
Ravi

Reputation: 8309

Have you tried JS Injection? You could use UIWebView's stringByEvaluatingJavaScriptFromString method and load local JS files. There's a tutorial I googled for. Here it is: http://www.ziconic.com/2010/10/javascript-injection-using-uiwebview.html

Upvotes: 1

Related Questions