Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/447.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iphone上的JavaScript_Javascript_Iphone_Html_Xcode_Webview - Fatal编程技术网

iphone上的JavaScript

iphone上的JavaScript,javascript,iphone,html,xcode,webview,Javascript,Iphone,Html,Xcode,Webview,我有个大问题 我在程序的WebView中使用HTML和JavaScript。当我设置路径时,他看到了一个Java脚本 但是如果javascript中的每个人都能在html中工作 问:如何正确设置javascript文件的路径 我找到了解决办法。很简单。我的JavaScript文件格式错误。如果你在UTF-8中成功,所有人都站在原地 而且很容易添加标准方式是 <script type="text/javascript" charset="utf-8" src="YourJSPath">

我有个大问题 我在程序的WebView中使用HTML和JavaScript。当我设置路径时,他看到了一个Java脚本

但是如果javascript中的每个人都能在html中工作

问:如何正确设置javascript文件的路径

我找到了解决办法。很简单。我的JavaScript文件格式错误。如果你在UTF-8中成功,所有人都站在原地 而且很容易添加

标准方式是

<script type="text/javascript" charset="utf-8" src="YourJSPath"></script>


因此,我修复了这个错误。事实上,它是用Javascript Foreman而不是UTF-8编写的,因为我知道xCode只支持UTF-8

您是否在问
标记从应用程序包中加载本地Javascript文件应该是什么样子的?可能与此问题相同:这是正确的,在WebView上连接了我的java脚本,但他拒绝打开“Kiyura”提示的选项之一,因为他确实在工作,但我的java脚本很大,不太想插入它,所以我想链接,但他不想看到他
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"file_name" ofType:@"file_type"];  
NSData *data = [NSData dataWithContentsOfFile:filePath];  
if (data) {  
  NSBundle *bundle = [NSBundle mainBundle]; 
  NSString *path = [bundle bundlePath];
  NSString *fullPath = [NSBundle pathForResource:@"file_name" ofType:@"file_type" inDirectory:path];
  [webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:fullPath]]];
}