[Drupal] How to add the js file and js code block in Drupal
Drupal 6:
代码
drupal_add_js(drupal_get_path('module', 'my_module') . '/my_module.js');
// This add inline JS to the head of the document
drupal_add_js('alert("Hello!")', 'inline');
// This will add variables in the Drupal.settings object
drupal_add_js(array('my_module' => array('my_setting' => 'this_value')), 'setting');
//add an external JS file to your site.
//You can not add <script XXXX />, but you have to add as <script XXX></script>,
//because the first one will cause some problem (webkit-base browser)
drupal_set_html_head('<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>');
Drupal 7:
drupal_add_js('misc/collapse.js', 'file');
drupal_add_js('jQuery(document).ready(function () { alert("Hello!"); });', 'inline');
drupal_add_js('jQuery(document).ready(function () { alert("Hello!"); });',
array('type' => 'inline', 'scope' => 'footer', 'weight' => 5)
);
drupal_add_js('http://example.com/example.js', 'external');
drupal_add_js(array('myModule' => array('key' => 'value')), 'setting');
Details: http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_add_js
转载于:https://www.cnblogs.com/davidhhuan/archive/2010/12/14/1905672.html
[Drupal] How to add the js file and js code block in Drupal相关推荐
- Tomcat 是怎么处理js file access request的
Sent: Tuesday, November 25, 2014 12:08 PM Tomcat 运行起来之后,通过这个url就能访问js文件: http://localhost:8080/cus.c ...
- JS file图片即选即得显示,前端交互图片即选即得
<table><tr><td><input type="file" name="sdfFile" id="s ...
- 收藏个支持进度条与文件拖拽上传的js File Uploader
File Uploader:支持进度显示与文件拖拽的多文件上传前端JS脚本 分类: JavaScript 2012-03-11 19:20 2028人阅读 评论(11) 收藏 举报 目录(?)[+] ...
- JS File 和 Blob 是什么
File / Blob 是什么 Blob 是最原始的文件对象,File 是基于 Blob 改造的,因此 Blob 的属性/方法在 File 中同样可以使用,你可以理解为 File === Blob,像 ...
- Unexpected use of file extention “js“ for “@/render/core/scale/index.js“
Unexpected use of file extention "js" for "@/render/core/scale/index.js" 解决方案:
- error TS6504: File ‘test01.js‘ is a JavaScript file. Did you mean to enable the ‘allowJs‘ option?
基于TypeScript执行命令为 这个正确执行ts文件的运行[会自动输出test01.js] tsc test01.ts 错误:这里是错误的运行方式[这里等价于tsc自动执行test01.js,为此 ...
- 942.ava.com_如何使用Ava.js测试Node.js应用程序
942.ava.com by Nitish Phanse 由Nitish Phanse 如何使用Ava.js测试Node.js应用程序 (How you can test your Node.js a ...
- Node.js「一」—— Node.js 简介 / Node.js 模块 / 包 与 NPM
本文为 Node.js 系列笔记第一篇.文章参考:nodejs 教程 -- 大地:<深入浅出 Node.js>:阮一峰 nodejs 博客 文章目录 一.Node 简介 1. 简单介绍 2 ...
- magento effects.js jquery.lazyload.js 冲突
2019独角兽企业重金招聘Python工程师标准>>> 当这两个js并存时,会造成加载图片闪烁的冲突问题 原因: jquery.lazyload.js会触发叫"appear ...
最新文章
- div+css中命名规范
- 学习笔记——一个指针有趣的问题
- RPA如何助力电信业数字化转型?
- 【常用技巧】标准模板库(STL)
- psql where里有自定义函数慢_使用gplearn自定义特征自动生成模块
- 加点自已内容的新内核下L7-FILTER的应用实例!
- CSRF漏洞原理/防御
- HDU1029——Ignatius and the Princess IV
- error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'产生原因
- WCF消息传输的几个基本概念(知识点整理)
- [数据结构] 三十二叉堆
- Mac谷歌浏览器chromedriver驱动安装教程,实现浏览器自动化
- 如何设置微信公众号多条被关注自动回复个性语
- 【寒江雪】Go实现Builder Pattern
- 帧率FPS,屏幕刷新频率赫兹Hz
- 第二课 什么是norm game?(An Evolutionary Approach to Norms)
- 我的世界java1.16.3村庄种子,我的世界2020年最新版村庄种子
- java list去除最后一个元素_如何快速删除list中的最后一个元素?
- 鸿蒙系统的软件怎么下载,怎么下载鸿蒙系统?
- ui设计现状与意义_UI设计的现状如何?
热门文章
- 前端学习(3011):vue+element今日头条管理--关于编辑器代码段
- [css] 如果css文件过大时,如何异步加载它?
- [css] 使用css写一个垂直翻转图片的效果
- 工作314:uni-提交成功加入表单验证
- [vue-element]项目中有使用过ElementUI吗?有遇到过哪些问题?它的使用场景主要是哪些?
- 工作74:vue带参数跳转其他页面
- 工作67:三级级联问题
- 前端学习(2381):代码提交
- 前端学习(1879)vue之电商管理系统电商系统之通过axios拦截器添加token认证
- 第八十二期:掌握这些监控报警优化技巧,百万年薪不在话下!