利用http的referer头和Servlet隐藏JavaScript代码
1. 定义一个用于输出JavaScript代码 的Servlet类。
package com.mycompany.response.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class HideJavaScript extends HttpServlet {
protected void service(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
response.setContentType("text/javascript;charset=UTF-8");
PrintWriter out = response.getWriter();
String referer = request.getHeader("referer");
if(!(referer==null)&&!referer.equalsIgnoreCase("")&&referer.startsWith("http://localhost:8080/response/"))
{
out.println("document.write('这些就是隐藏的JavaScript代码!')");
out.println("window.alert('执行了此代码!')");
}
&n
相关文档:
翻译:为之漫笔
链接:http://www.cn-cuckoo.com/2007/08/01/understand-javascript-closures-72.html
简介
基于对象的属性名解析
值的指定
值的读取
标识符解析、执行环境和作用域链
执行环境
作用域链与 [[scope]]
标识符解析
闭包
自动垃圾收集
构成闭包
通过闭包可以做什么?
例 1:为函数 ......
第一种:
+展开
-HTML
<html>
<head>
</head>
<body>
<form name="form1">
<input type="text" name="getinfo" value="http://www.shuwo.net" size="40"><button onclick="alert(document.form1.getinfo.value ......
用一个正侧表达式在javascript中验证就是咯!
<script language='javascript'>
function chkMail(){
if(document.form1.email.value=''){
alert("请填写邮箱地址!");
document.form1.email.focus();
return false;
}
//开始验证
var email = document.form1.email.value;
var pattern = /^([a-zA-Z0-9_-]) ......
<script language="javascript">
function closeOpen(Panel) {
var test = document.getElementById('Panel');
if (test.style.display == "none") {
&nb ......