后台输出js字符串,怎么样让前台自动执行 后台代码:this.adContent="<script src="http://192.168.0.157:8080/Ajax/ad_sys.ashx?width=480&height=200&style=1" type="text/javascript">"; //这个js字符串从数据库中取的怎样让页面执行,上面这样写不行 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 一般JAVA中response.write("<script>alert('123')</script>");就可以在页面中执行javascript里的内容了,可以先测试下,大概是这样。 src="http://192.168.0.157:8080/Ajax/ad_sys.ashx?width=480&height=200&style=1"这个地址里面输出的是一张图片啊 1、LZ的后台用的是什么2、LZ的图片的意图是要在前台显示出来吗? Java举例:后台request.setAttribute('code',this.adContent);//this.adContent在这里我觉得可以改成url字符串前台jsp中使用el表达式获得即可<body> This is my JSP page. <br> <img src="${code}"> <!- 图片出来了--> </body> 服务器端:response.write("<script src='http://192.168.0.157:8080/Ajax/ad_sys.ashx?width=480&height=200&style=1' type='text/javascript'>");浏览器端动态载入js:// 动态导入jsfunction 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 加载完成后的回调函数,可以不要此参数 */}); 改成this.adContent='<script src="http://192.168.0.157:8080/Ajax/ad_sys.ashx?width=480&height=200&style=1" type="text/javascript">';试试? 图片编辑 正则 看看如下代码什么问题(目的在实现动态绑定控件的事件) 求一个基于Jquery的日历插件。。。。 鼠标移动到gridpanel行上 变色问题 高亮如何改颜色? 这种数组格式在JS中怎么形成呢? js改写属性需要重构页面吗? 求正则匹配windows本地文件路径是否合法的js 关于window.open 的一个问题!! FOCUS时出错 求助:当鼠标滑过某一个选项后,显示该选项下面的 所有信息,其他选择的内容全部隐藏。 如何在服务器端压缩javascript和css文件
src="http://192.168.0.157:8080/Ajax/ad_sys.ashx?width=480&height=200&style=1"这个地址里面输出的是一张图片啊
2、LZ的图片的意图是要在前台显示出来吗?
后台request.setAttribute('code',this.adContent);//this.adContent在这里我觉得可以改成url字符串
前台jsp中使用el表达式获得即可
<body>
This is my JSP page. <br>
<img src="${code}"> <!- 图片出来了-->
</body>
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 加载完成后的回调函数,可以不要此参数 */});
改成
this.adContent='<script src="http://192.168.0.157:8080/Ajax/ad_sys.ashx?width=480&height=200&style=1" type="text/javascript">';试试?