首页 > 代码库 > 在网页中使用javascript提供反馈信息

在网页中使用javascript提供反馈信息

一,使用document.write()

二,使用window方法,prompt(),alert()和confirm()

 

<html lang="en">
<head>
  <title>Search example</title>
<script type="text/javascript">
function checkSearch()
{
       if(!document.getElementById||!document.createTextNode){return;}
       if(!document.getElementById(‘search‘)){return;}    //通过元素的ID特性来获取元素
       var searchValue=http://www.mamicode.com/document.getElementById(‘search‘).value;
       if(searchValue=http://www.mamicode.com/=‘‘)
       {
           alert(‘Please enter a search term‘);
           return false;
       }
       else if(searchValue=http://www.mamicode.com/=‘JavaScript‘)
       {
           var really=confirm(‘"JavaScript" is tt very common term.\n‘+
           ‘Do you really want to search for this?‘);
           return really;
       }
       else
       {
           return true;
       }
}
</script>
</head>
<body>
  <form action="sitesearch.php" method="post" onsubmit="return checkSearch()">
  <p>
  <label for="search">Search the site:</label>
  <input type="text" id="search" name="search"/>
  <input type="submit" value=http://www.mamicode.com/"Search"/>
  </p>
  </form>
</form>
</body>
</html>

在网页中使用javascript提供反馈信息