Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/473.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
Javascript jquery mobile中包含大量html文档时链接和嵌入js文件_Javascript_Jquery_Html_Jquery Mobile_Cordova - Fatal编程技术网

Javascript jquery mobile中包含大量html文档时链接和嵌入js文件

Javascript jquery mobile中包含大量html文档时链接和嵌入js文件,javascript,jquery,html,jquery-mobile,cordova,Javascript,Jquery,Html,Jquery Mobile,Cordova,大家好,我是Jquery mobile的新手。我需要开发由很多屏幕组成的移动应用程序。我的应用程序中大约有50个html。我面临的这个问题是nw哪个是hw链接到彼此的页面 顺便说一句,我需要将cordova.js或自定义js文件嵌入到所有页面。那么,我是否需要将java脚本文件嵌入到每50页的页眉中?重组我的应用程序非常耗时 比如说 <head> <meta charset="utf-8"> <title>Smart Realtor</title

大家好,我是Jquery mobile的新手。我需要开发由很多屏幕组成的移动应用程序。我的应用程序中大约有50个html。我面临的这个问题是nw哪个是hw链接到彼此的页面

顺便说一句,我需要将cordova.js或自定义js文件嵌入到所有页面。那么,我是否需要将java脚本文件嵌入到每50页的页眉中?重组我的应用程序非常耗时 比如说

    <head>
<meta charset="utf-8">
<title>Smart Realtor</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes">  
<meta name="apple-mobile-web-app-status-bar-style" content="black"> 

<link rel="stylesheet" href="css/smartrealtor-theme.css" />
<link rel="stylesheet" type="text/css" href="css/snap.css" />
<link rel="stylesheet"  href="css/custom.css"> 
<link rel="stylesheet"  href="css/themes/default/jquery.mobile.structure-1.4.2.css">
<link rel="stylesheet"  href="css/themes/default/jquery.mobile.icons-1.4.2.css">
<link rel="stylesheet"  href="css/jqm-icon-pack-fa.css">
<script src="js/jquery.js"></script>
<script src="js/globalsetting.js"></script>
<script src="js/jquery.mobile-1.4.2.min.js"></script>

</head>

精明的房地产经纪人

Jquery mobile是否提供了类似于我只需要将js文件包含到index.html的功能。然后我的另一个页面将自动加载这些js文件。请指导我的解决方案,并提供一些示例代码,而不是给我jquery移动文档链接。谢谢

好的,我想澄清一下,听起来你有两个问题:

  • 向所有50个html文件添加导航链接
  • 向所有50个html文件添加额外的javascript源代码
  • 我想到了两种基本方法:

    • 您可以编写脚本或使用程序为html目录中的所有文件执行文本查找和替换。如果你想使用一个程序,你可以使用或类似的工具。如果你想使用一个脚本,那么你可以用你喜欢的任何东西来编写它,我可能会使用Python,可能会帮助你编写这样一个脚本。因此,要添加导航链接并嵌入额外的javascript文件,您可以搜索
      ,并替换为:
      
      

    • 另一个可能的选择是添加导航,并使用一个javascipt文件动态加载javascript文件,该文件已经包含在所有html文件中。但是请注意,与直接更改html文件(如前一种方法)相比,这种方法将略微降低页面的性能。例如,要加载额外的javascript源代码,可以将以下代码添加到globalsetting.js
      使用
      
      $(文档).ready(函数(){
      $.getScript(“js/cordova.js”,函数(数据、文本状态、jqxhr){
      console.log(数据);//返回的数据
      console.log(textStatus);//成功
      console.log(jqxhr.status);//200
      日志(“加载已执行”);
      });
      });
      
      或者作为普通javascript(,)
      
      var head=document.getElementsByTagName('head')[0];
      var script=document.createElement('script');
      script.type='text/javascript';
      script.src='helper.js';
      head.appendChild(脚本);
      
      要添加导航,可以将以下jQuery代码添加到globalsetting.js:()
      
      $(“正文”)。附加(“
      ")