1.
<html>
<head>
<title></title>
<script type="text/javascript">
function register(fn,text){
var head = document.getElementsByTagName("head")[0];
var script = document.createElement("script");
script.type = "text/javascript";
script.text = "function " + fn + "() {" + text + "}";
head.appendChild(script);
}
function say(){}
</script>
</head>
<body>
<input type="text" value="alert('We will rockyou')" onclick="register('say',this.value)"/>
<input type="button" onclick="say()" />
</body>
</html>
<html>
<head>
<title></title>
<script type="text/javascript">
function register(fn,text){
var head = document.getElementsByTagName("head")[0];
var script = document.createElement("script");
script.type = "text/javascript";
script.text = "function " + fn + "() {" + text + "}";
head.appendChild(script);
}
function say(){}
</script>
</head>
<body>
<input type="text" value="alert('We will rockyou')" onclick="register('say',this.value)"/>
<input type="button" onclick="say()" />
</body>
</html>