iosWebView載入本地js

來源:互聯網
上載者:User

標籤:本地載入

ASIHTTPRequest *request=[ASIDataService GET_Path:path completed:^(id JSON, NSString *stringData) {        //擷取到html資訊        //NSLog(@"jason%@,stringdata%@",JSON,stringData);        //修改html資訊        NSString *htmlString=[stringData stringByReplacingOccurrencesOfString:@"http://s.fwxgx.com/jquery_mobile/jquery.mobile-1.4.5.min.css" withString:@"jquery.mobile-1.4.5.min.css"];        htmlString=[htmlString stringByReplacingOccurrencesOfString:@"http://s.fwxgx.com/jquery_mobile/jquery-1.11.1.min.js" withString:@"jquery-1.11.1.min.js"];        htmlString=[htmlString stringByReplacingOccurrencesOfString:@"http://s.fwxgx.com/jquery_mobile/jquery.mobile-1.4.5.min.js" withString:@"jquery.mobile-1.4.5.min.js"];        //htmlString=[stringData stringByReplacingOccurrencesOfString:@"/survey/save_train_survey" withString:@"http://gmsa.fwxgx.com/survey/save_train_survey"];        //寫入本地檔案        /*        NSString *successPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Success.text"];        NSArray *[email protected][[NSString stringWithFormat:@"%@/%@",filePath,name]];        NSDictionary *[email protected]{@"Root":SuccessArray};                BOOL success = [dic writeToFile:successPath atomically:YES];         */        NSLog(@"/n html%@",htmlString);        [webView loadHTMLString:htmlString baseURL:[NSURL fileURLWithPath:[ [NSBundle mainBundle] bundlePath]]];        [self.view addSubview:webView];            } failed:^(NSError *error) {        NSLog(@"資料失敗");    }];

JS檔案只能手動放到copyResourc裡面,不能作為可編譯檔案,另外由於html字串過長,編譯器不會全部顯示

iosWebView載入本地js

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.