我想把下面的代码放到 document.write(''); 里去,请问该怎么写才对呢?请给我代码呀。<td onMouseOver="this.bgcolor='+ td_bgcolor+ '"  >其中 td_bgcolor 是 javascript 中的变量。我同时在 javascript 栏目也问了同样的问题,知道的一起去拿分。

解决方案 »

  1.   

    document.write("<td onMouseOver=\"this.bgcolor='+ td_bgcolor+ '\"  >");
      

  2.   

    document.write("<td onMouseOver="+"\"this.bgcolor="+"\'"+ td_bgcolor+ "\'" +" >"
    )
      

  3.   

    document.write("<td onMouseOver=this.bgcolor='"+ td_bgcolor+ "'>");
      

  4.   

    不能用啊,实际上 
    正确的: <td onMouseOver="this.bgcolor='red'"  > 
    错误的: <td onMouseOver="this.bgcolor=red"  > 
    也就是说,还少一个单引号,或者是双引号的
      

  5.   

    document.write("<td onMouseOver="+"\"this.bgcolor="+"\'"+ td_bgcolor+ "\'" +" >")
      

  6.   

    document.write("<td onMouseOver=\"this.style.bgcolor='\""+ td_bgcolor+ "'\">");
      

  7.   

    to: renaski(洛林)document.write("<td onMouseOver=this.bgcolor='"+ td_bgcolor+ "'>");这个语句在 JAVASCRIPT 中 onMouseOver= “this.****” THIS 这个地方需要一个双引号,你可简单试一下。
      

  8.   

    哦?是吗?<table>
    <tr><td bgcolor=red onmouseover=this.bgColor='#CCCCCC'>dsfadsafdfdsaafdsafds</td></tr>
    <table>
      

  9.   

    <td onMouseOver="this.bgcolor='+ td_bgcolor+ '"  >
    你自己题目不把
    bgcolor
    中的C变成了小写
    还要怪别人。
    真是的。
      

  10.   

    楼上的
    我没有IQ卡,只有IQ
      

  11.   

    to :  renaski(洛林) 啊,真抱歉,你是正确的, 150 分将会全部送给你,即使你不回答下面的这个问题我也会照样送给你我还有一个小的衍生问题呀,我是在代码中写入的,即它是这样的
    Response.Write("document.write('<td  align=center  onMouseOver=this.bgColor=" + hover_text_bgcolor + ">');")我这行代码哪错了,就是不行啊。
      

  12.   

    得。
    算了。
    对了,你再写.net吧,为什么写脚本要用response.write 方法写呢?这个是第1个。
    第2个要写的话,我认为最好也写成个js到时候<script>aa()</script>
    去调用他。
      

  13.   

    RegisterClientScriptBlock方法,还有一个state的。
    具体的google
    sdk
      

  14.   

    Response.Write("document.write('<td  align=center  onMouseOver=this.bgColor=" + hover_text_bgcolor + ">');")
    能告诉我报什么错吗?
      

  15.   

    最近才搞 .NET 。我是想写一个文本链,直接调用,对 JS 并不熟,以前在公司是写 WINFORM 。网站弄得少, JAVASCRIPT 脚本并不懂,大都是抄来的。嘻嘻~! Response.Write("document.write('<td  align=center  onMouseOver=this.bgColor=" + hover_text_bgcolor + ">');")这行代码中 hover_text_bgcolor 是JAVASCRIPT 的变量
    不能看到效果,提示我 hover_text_bgcolor 变量没声时。因为 hover_text_bgcolor 这个变量在 界面里面声明的,不知道怎么处理。就是希望能用 Response.Write 方法写出来。
      

  16.   


    Response.Write("<script>hover_text_bgcolor=red;document.write('<td  align=center  onMouseOver=this.bgColor=" + hover_text_bgcolor + ">');</script>")
      

  17.   

    不行,这个地方,hover_text_bgcolor  必须成为字串的一部分
      

  18.   

    Response.Write("<script>hover_text_bgcolor="red";document.write('<td  align=center  onMouseOver=this.bgColor=" + hover_text_bgcolor + ">');</script>")
    我这里写错了,少了“”
    你说的是什么意思?
      

  19.   

    你上面,red 不就成了变量啦 ? ,得我还是自己研究一下其它的方法吧~! 你分别在  ASP ,JAVASCRIPT 回复一下,我分都送给你吧。
      

  20.   

    提示 hover_text_bgcolor 变量没声明哈,这个问题我知道!如果你代码没问题的前提下。打个比方,你aspx页面上有个function haha()你想在后台代码写Response.Write("<script>haha()</script>");来执行haha(),是执行不了的,IE会提示你缺少变量。因为服务器端运行会生成整个aspx,而Response.Write最先执行!然后才读取aspx原静态的东西,所以IE找不到function haha(),不信你看查看网页源代码。解决方法:
    1.aspx里面把js写到<From1>前面,
    2.在aspx添加一个<div id="DIV1"  runat="server"></div>
    3.aspx.cs
     DIV1.innerHTML = "<script>haha();</script>";