Resource files are placed under the root directory
1, index.html
<title>my Test page</title>
<link rel= "stylesheet" href = "test.css" type= "Text/css"/>
<script type = "Text/javascript" src = "22.js" ></script>
<body>
<H1 id= "food" onclick = "SayHello ()" >click me!
</body>
2, 22.js
function SayHello () {
if (document.getElementById (' foo '). InnerHTML = = ' Hi there ') {
document.getElementById (' foo '). InnerHTML = ' Click me! ' ;
}Else{
document.getElementById (' foo '). InnerHTML = ' Hi there ';
}
}
3, Test.css
body{
color:red;
background-color:#fff;
font-size:px;
font-style:italic;
font-weight:bold;
font-family: Arial;
}
4. OC Code
WEbview = [[uiwebview alloc] initwithframe: [[uiscreen mainscreen ] [ bounds]];
[self. View addsubview:iwebview];
[webview setbackgroundcolor: [uicolor whitecolor]];
NSString *path = [[NSBundle mainbundle] bundlepath];< /c19>
nsurl *baseurl = [nsurl fileurlwithpath:p ath];
nsstring *imagestr=[ nsstring stringwithcontentsofurl:[ Nsurl urlwithstring:@ "http://192.168.1.155/ Index.html "" encoding:nsutf8stringencoding< span class= "s2" > error:nil];
[webview loadhtmlstring: Imagestr baseURL: BaseURL];
5, the principle is to first pull down the server HTML, and then load the local HTML by webview the way load,
UIWebView loading local js, CSS, img,html loading from the website