在javascript文件中使用jstl标签
今天看到同事harry_duan写的一个js文件,感觉挺有意思。
目地是在js文件中使用jstl的fmt:message
1.在资源文件中定义消息 errors.message1=error xxxxxx
2.创建一个js文件,为了jstl能用,将js文件命名为 myjs.js.jsp (以jsp结尾)
js 代码
<%@ page contentType="text/html; charset=utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
showMessage = function() {
alert("<fmt:message key="errors.message1"></fmt:message>");
}
3.在jsp中引用这个js文件
xml 代码
<script type="text/javascript" src="js/myjs.js.jsp">script>
<input type="button" onclick="javascript: showMessage();" value="showMessage">
这样就OK了
相关文档:
写一个小系统时,需要动态添加表单元素,按自己的实现方法写了这篇教程!
我想各位在很多网站上都看到过类似的效果!
1、先用document.createElement方法创建一个input元素!
程序代码
var newInput = document.createElement("input");
2、设定相关属性,如name,type等
程序代码
newInput.type=mytype;
newInput.name ......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0041)/ -->
<html xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<TITLE>JavaScript仿Excel表格演示- /</TITLE>
< ......
<html>
<head>
<script type="text/javascript">
function goHome(){
  ......
jQuery片段:
var
// Will speed up references to window, and allows munging its name.
window = this,
// Will speed up references to undefined, and allows munging its name.
undefined,
// Map over jQuery in case of overwrite
_jQuery = window.jQuery,
// Map over the $ in case of overwrit ......
function AddDropDownList(id,fatherCtl)
{
if(!document.getElementById(id))
{
var ddl = document.createElement('select');
ddl.s ......