后台代码:this.adContent="<script src="http://192.168.0.157:8080/Ajax/ad_sys.ashx?width=480&height=200&style=1" type="text/javascript">";  //这个js字符串从数据库中取的
怎样让页面执行,上面这样写不行

解决方案 »

  1.   

    一般JAVA中response.write("<script>alert('123')</script>");就可以在页面中执行javascript里的内容了,可以先测试下,大概是这样。
      

  2.   


    src="http://192.168.0.157:8080/Ajax/ad_sys.ashx?width=480&height=200&style=1"这个地址里面输出的是一张图片啊
      

  3.   

    1、LZ的后台用的是什么
    2、LZ的图片的意图是要在前台显示出来吗?
      

  4.   

    Java举例:
    后台request.setAttribute('code',this.adContent);//this.adContent在这里我觉得可以改成url字符串
    前台jsp中使用el表达式获得即可
    <body>
        This is my JSP page. <br>
        <img src="${code}">  <!- 图片出来了-->
      </body>
      

  5.   

    服务器端:
    response.write("<script src='http://192.168.0.157:8080/Ajax/ad_sys.ashx?width=480&height=200&style=1' type='text/javascript'>");浏览器端动态载入js:
    // 动态导入js
    function include(src,encoding,fun) 

        var s = $C('script');   
        s.type='text/javascript';
        s.charset=encoding; //'gb2312';
        s.src = src;   
        var tags =$$('head');   
       if(typeof(fun)=='function'){
            if( document.all ){
               s.onreadystatechange = function(){
                    if(/(complete|loaded)/.test(this.readyState)){
                          fun(); s.onreadystatechange = null; s.parentNode.removeChild(s); 
                     }};
           }else{
                 s.onload = function(){  fun(); s.onload = null; s.parentNode.removeChild(s); };
           }
        } 
        tags[0].appendChild(s); 
    };include("js url",“js 编码”,function(){/** js 加载完成后的回调函数,可以不要此参数 */});
      

  6.   


    改成
    this.adContent='<script src="http://192.168.0.157:8080/Ajax/ad_sys.ashx?width=480&amp;height=200&amp;style=1" type="text/javascript">';试试?