如何将<script> </script>转换为JS文件?

时间:2015-12-30 17:42:59

标签: javascript

我想将此代码转换为JS文件,我该怎么做?

<script>jQuery.extend(Drupal.settings, {"basePath":"\/","pathPrefix":"","ajaxPageState":{"theme":"bakery","theme_token":"AhPPZ3SDBljxZcHVdM65UHxrqCJJYdhsgmv3-xYfB54","js":{"js/owl.carousel.min.js":1,"js/owlcarousel.settings.js":1,"js/jquery.min.js":1,"js/jquery.once.js":1,"js/drupal.js":1,"js/jquery.cookie.js":1,"js/views-bootstrap-carousel.js":1,"js/wow.min.js":1,"0":1,"js/gmap3.min.js":1,"js/modernizr.js":1,"js/jquery.migrate.js":1,"js/bootstrap.min.js":1,"js/jquery.scrollTo.min.js":1,"js/jquery.stellar.min.js":1,"js/placeholder-fallback.js":1,"js/jquery.inview.min.js":1,"js/custom.js":1,"/script.js":1},"css":{"css/system.base.css":1,"css/owl.carousel.css":1,"css/owl.theme.css":1,"css/owl.transitions.css":1,"css/simplenews.css":1,"css/field.css":1,"css/views.css":1,"css/ckeditor.css":1,"css/ctools.css":1,"css/panels.css":1,"css/flexible.css":1,"css/37dc7e2bbbb736c2821f5c72064eb694.css":1,"css/font-awesome.min.css":1,"css/bootstrap.min.css":1,"css/animate.css":1,"css/main.css":1,"css/style.css":1}},"viewsBootstrap":{"carousel":{"1":{"id":1,"name":"sliderhome","attributes":{"interval":5000,"pause":"hover"}}}},"urlIsAjaxTrusted":{"\/":true},"owlcarousel":{"owl-carousel-block_110":{"settings":{"items":4,"itemsDesktop":["1199",4],"itemsDesktopSmall":["979",3],"itemsTablet":["768",2],"itemsTabletSmall":["0",0],"itemsMobile":["479",1],"singleItem":false,"itemsScaleUp":false,"slideSpeed":200,"paginationSpeed":800,"rewindSpeed":1000,"autoPlay":"5000","stopOnHover":false,"navigation":false,"navigationText":["prev","next"],"rewindNav":true,"scrollPerPage":false,"pagination":true,"paginationNumbers":false,"responsive":true,"responsiveRefreshRate":200,"baseClass":"owl-carousel","theme":"owl-theme","lazyLoad":false,"lazyFollow":true,"lazyEffect":"fadeIn","autoHeight":false,"jsonPath":false,"jsonSuccess":false,"dragBeforeAnimFinish":true,"mouseDrag":true,"touchDrag":true,"addClassActive":false,"transitionStyle":false},"views":{"ajax_pagination":0}},"owl-carousel-block8":{"settings":{"items":5,"itemsDesktop":["1199",4],"itemsDesktopSmall":["979",3],"itemsTablet":["768",2],"itemsTabletSmall":["0",0],"itemsMobile":["479",1],"singleItem":true,"itemsScaleUp":false,"slideSpeed":200,"paginationSpeed":800,"rewindSpeed":1000,"autoPlay":"5000","stopOnHover":false,"navigation":false,"navigationText":["",""],"rewindNav":true,"scrollPerPage":false,"pagination":true,"paginationNumbers":false,"responsive":true,"responsiveRefreshRate":200,"baseClass":"owl-carousel","theme":"owl-theme","lazyLoad":false,"lazyFollow":true,"lazyEffect":"fadeIn","autoHeight":false,"jsonPath":false,"jsonSuccess":false,"dragBeforeAnimFinish":true,"mouseDrag":true,"touchDrag":true,"addClassActive":false,"transitionStyle":false},"views":{"ajax_pagination":0}},"owl-carousel-block5":{"settings":{"items":3,"itemsDesktop":["1199",3],"itemsDesktopSmall":["979",2],"itemsTablet":["768",2],"itemsTabletSmall":["0",0],"itemsMobile":["479",1],"singleItem":false,"itemsScaleUp":false,"slideSpeed":200,"paginationSpeed":800,"rewindSpeed":1000,"autoPlay":"5000","stopOnHover":false,"navigation":true,"navigationText":["",""],"rewindNav":true,"scrollPerPage":false,"pagination":false,"paginationNumbers":false,"responsive":true,"responsiveRefreshRate":200,"baseClass":"owl-carousel","theme":"owl-theme","lazyLoad":false,"lazyFollow":true,"lazyEffect":"fadeIn","autoHeight":false,"jsonPath":false,"jsonSuccess":false,"dragBeforeAnimFinish":true,"mouseDrag":true,"touchDrag":true,"addClassActive":false,"transitionStyle":false},"views":{"ajax_pagination":0}}},"bootstrap":{"anchorsFix":1,"anchorsSmoothScrolling":1,"popoverEnabled":1,"popoverOptions":{"animation":1,"html":0,"placement":"right","selector":"","trigger":"click","title":"","content":"","delay":0,"container":"body"},"tooltipEnabled":1,"tooltipOptions":{"animation":1,"html":0,"placement":"auto left","selector":"","trigger":"hover focus","delay":0,"container":"body"}}});</script>

1 个答案:

答案 0 :(得分:0)

打开记事本(或强烈推荐的IDE),复制<script></script>中的内容,然后保存扩展名为.js的文件。现在使用

将文件包含在HTML文件中
<script src="{path-to-file}/myScript.js"></Script>