如何实现自动执行代码?
以下是一段代码,意思是:先读取剪贴板的内容,然后鼠标点击超链接“Get clipboard data”就会在文本框中显示剪贴板内容
但我想要自动执行超链接中的函数“javascript:setCB()”
意思就是自动在文本框中显示剪贴板的内容。要怎么样才能实现呢?恭请高手指教。不胜感激!!!!
<html>
<head>
<title> Sample </title>
<script language= "JavaScript "> <!--
function setCB()
{
document.myFORM.myTA.value = window.clipboardData.getData( "Text ");
}
// --> </script>
</head>
<body>
<a href= "javascript:setCB() "> Get clipboard data </a> <br>
<form name= "myFORM ">
<input cols= "40 " rows= "10 " name= "myTA "> </input>
</form>
</body>
</html>
------解决方案--------------------但我想要自动执行超链接中的函数“javascript:setCB()” ????
<html>
<head>
<title> Sample </title>
<script language= "JavaScript "> <!--
function setCB()
{
document.myFORM.myTA.value = window.clipboardData.getData( "Text ");
}
// --> </script>
</head>
<body>
<a href= "javascript:setCB() "> Get clipboard data </a> <br>
<form name= "myFORM ">
<input cols= "40 " rows= "10 " name= "myTA "> </input>
</form>
<script>
setCB();//就这里调用一下
</script>
</body>
</html>