<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<SCRIPT   LANGUAGE="JavaScript">   
  <!--   
  
  //判断左右键   
  function  document.onmousedown()   {   if(event.button==2){
   alert("右键");
   document.body.style.background="red";
  }else if(event.button==1){
  alert("左键");
  document.body.style.background="";
  } 
  document.getElementById("div1").innerText="Welcome To My Site1 ";
 }   
  
  //-->   
  </SCRIPT> </HEAD><BODY>
<input type="button" onclick="aa()" value="点这里">
<div id="div1"></div>
</BODY>
</HTML>

解决方案 »

  1.   

    <html>
    <head>
    <META http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head>
    <SCRIPT language=JavaScript1.2>
    function choosebg(obj)
    {
    obj=window.event;
    if (obj.button==2 || obj.button==3)
        document.body.style.background="red";
        else
        document.body.style.background="";
    }
    </script>
    <body bgcolor="#CCCCCC" id="ba">
    <img src="pang.jpg" width="600" height="800" onMouseDown="choosebg();" alt="Welcome to my website!!~!~">
    </body>
    </html>
      

  2.   

    简单分析如下:
    1、通过你在图片上的鼠标事件来使用Window.event
    2、通过event.button来判断是左还是右键[2,3]
    3、通过document.body.style.background=来更改Body的颜色
    4、至于你说的“Welcome",我想,你应该是针对图片来说的吧,直接在图片的alt标识中加上“welcome...",只要将鼠标放到图片上,就会显示“welcome"。
      

  3.   

    要是只是在特定的地方,比方说第三行插入代码<font size=12>Welcome to here</front>,用document.write应该怎么写呢?
      

  4.   

    <script>
    document.write ("<font size=12>Welcome to here</front>");
    </script>
      

  5.   

    <script>
    document.write ("<font size=12>Welcome to here</front>");
    </script>
    这样写的这个页面的其他内容就没了,不知道怎么回事!