<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
.form_text_search_keyword {
border-style: none;
float: right;
background-image: url(form_text_search_keyword.jpg);
width: 200px;
height: 200px;
font-size: 18px;
}
</style>
<style type="text/javascript">
function formkcus(x){
document.getElementById(x).value="aaa"
}
</style>
</head><body style="background:#3CF">
<form action="mylist.php" method="get">
  <input type="text" id="forddword" class="form_text_search_keyword" name="search" autocomplete="on" value="请输入关键字" onfocus="formkcus(this.id)">
</form>
</body>
</html>
JavaScriptinputtextvalueonfocus

解决方案 »

  1.   

    囧,你包含js的代码怎么是<style>?????
    <style type="text/javascript">
    function formkcus(x){
    document.getElementById(x).value="aaa"
    }
    </style>改成<script>
      

  2.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <style type="text/css">
    .form_text_search_keyword {
    border-style: none;
    float: right;
    background-image: url(form_text_search_keyword.jpg);
    width: 200px;
    height: 200px;
    font-size: 18px;
    }</style>
    <script>
    function formkcus(x){
       document.getElementById(x).value="aaa";
    }
    </script>
    </head><body style="background:#3CF">
    <form action="mylist.php" method="get">
      <input type="text" id="forddword" class="form_text_search_keyword" name="search" autocomplete="on" value="请输入关键字" onfocus="javascript:formkcus(this.id)">
    </form>
    </body>
    </html>
      

  3.   

    首先楼主 formkcus 位定义成函数,其次楼主的js声明不对