弄了一个js的循环广告代码,直接放在程序里执行没有问题,我想放在一个单独的js文件里,然后在别的页面<script src="1.js"></script>来调用,这个js文件该怎么写?我试验了好几个方法都在别的页面不执行,贴代码出来
这是广告循环的代码
----------------------------------------------------------------------
<script src="js/swfobject.js" type="text/javascript"></script> <div id="flashad" class="tnone">动画载入中...
<script type="text/javascript">var swf_width=890
var swf_height=109
var config='2|0xcc0000|0xffffff|50|0xffffff|0xff9900|0xff3300'var files='GG/1.jpg|GG/2.jpg|GG/3.jpg'
var links='#|#|#|#|#'
var texts='|||||' var so = new SWFObject("js/flashad.swf", "mymovie", swf_width, swf_height, "8");
so.addVariable("bcastr_flie", files);
so.addVariable("bcastr_link", links);
so.addVariable("bcastr_title", texts);
so.addVariable("config", config);
so.write("flashad");
</script>
</div>
------------------------------------------------------------------------------
这是 1.js 文件里的代码,我试验了好多方法都不执行,document.write一行行的写也不行------------------------------------------------------------------------------
var last
last =''
last = last + '<script src="js/swfobject.js" type="text/javascript"></script>'
last = last + '<div id="flashad" class="tnone">动画载入中..'
last = last + '<script language="javascript">'
last = last + 'var swf_width=890;'
last = last + 'var swf_height=109 ; '
last = last + 'var config="2|0xcc0000|0xffffff|50|0xffffff|0xff9900|0xff3300";'
last = last + 'var files="GG/1.jpg|GG/2.jpg|GG/3.jpg";'
last = last + 'var links="#|#|#|#|#" ;var texts="|||||" ;'
last = last + 'var so = new SWFObject("js/flashad.swf", "mymovie", swf_width, swf_height, "8");'
last = last + 'so.addVariable("bcastr_flie", files);'
last = last + 'so.addVariable("bcastr_link", links);'
last = last + 'so.addVariable("bcastr_title", texts);'
last = last + 'so.addVariable("config", config);'
last = last + 'so.write("flashad");'
last = last + '</script>'
last = last + '</div>'
document.write(last);---------------------------------------------------------------------------------
求解决方法,最好贴出代码来。
---------------------------------------------------------------------------------
这是广告循环的代码
----------------------------------------------------------------------
<script src="js/swfobject.js" type="text/javascript"></script> <div id="flashad" class="tnone">动画载入中...
<script type="text/javascript">var swf_width=890
var swf_height=109
var config='2|0xcc0000|0xffffff|50|0xffffff|0xff9900|0xff3300'var files='GG/1.jpg|GG/2.jpg|GG/3.jpg'
var links='#|#|#|#|#'
var texts='|||||' var so = new SWFObject("js/flashad.swf", "mymovie", swf_width, swf_height, "8");
so.addVariable("bcastr_flie", files);
so.addVariable("bcastr_link", links);
so.addVariable("bcastr_title", texts);
so.addVariable("config", config);
so.write("flashad");
</script>
</div>
------------------------------------------------------------------------------
这是 1.js 文件里的代码,我试验了好多方法都不执行,document.write一行行的写也不行------------------------------------------------------------------------------
var last
last =''
last = last + '<script src="js/swfobject.js" type="text/javascript"></script>'
last = last + '<div id="flashad" class="tnone">动画载入中..'
last = last + '<script language="javascript">'
last = last + 'var swf_width=890;'
last = last + 'var swf_height=109 ; '
last = last + 'var config="2|0xcc0000|0xffffff|50|0xffffff|0xff9900|0xff3300";'
last = last + 'var files="GG/1.jpg|GG/2.jpg|GG/3.jpg";'
last = last + 'var links="#|#|#|#|#" ;var texts="|||||" ;'
last = last + 'var so = new SWFObject("js/flashad.swf", "mymovie", swf_width, swf_height, "8");'
last = last + 'so.addVariable("bcastr_flie", files);'
last = last + 'so.addVariable("bcastr_link", links);'
last = last + 'so.addVariable("bcastr_title", texts);'
last = last + 'so.addVariable("config", config);'
last = last + 'so.write("flashad");'
last = last + '</script>'
last = last + '</div>'
document.write(last);---------------------------------------------------------------------------------
求解决方法,最好贴出代码来。
---------------------------------------------------------------------------------
解决方案 »
- 请问:我发现有的项目是structs-config.xml的文件名改了,改成其它的名字,比如structs.xml,结果也能运行,这是怎么回事啊?
- EJB与JAVA BEAN的区别?
- 有人知道怎么用ireport画表格吗?
- 求助JSP学习及开发所需要的所有软件
- 怎么在jsp页面中显示一个倒计时?有外用的js麻烦传一下
- 问一个数据库索引的问题!
- 请教大家哪有下载jbuilder的网址????
- jsp中使用 javaBean出现错误
- 怎么改呀,多谢!
- java调用https的webservice接口
- JBOSS应用报错:Servlet.service() for servlet HtmlAdaptor threw exception
- 送分---进来回答我的问题 字段问题
var swf_height=109
var config='2 ¦0xcc0000 ¦0xffffff ¦50 ¦0xffffff ¦0xff9900 ¦0xff3300' var files='GG/1.jpg ¦GG/2.jpg ¦GG/3.jpg'
var links='# ¦# ¦# ¦# ¦#'
var texts=' ¦ ¦ ¦ ¦ ¦' var so = new SWFObject("js/flashad.swf", "mymovie", swf_width, swf_height, "8");
so.addVariable("bcastr_flie", files);
so.addVariable("bcastr_link", links);
so.addVariable("bcastr_title", texts);
so.addVariable("config", config);
so.write("flashad");
问题出在这句,当你的js执行时这个js文件其实没有载入页面上包含这句
<script src="js/swfobject.js" type="text/javascript"> </script>然后在你的js文件里面,改成这样var last
last =''
last = last + ' <div id="flashad" class="tnone">动画载入中..'
last = last + ' <script language="javascript">'
last = last + 'var swf_width=890;'
last = last + 'var swf_height=109 ; '
last = last + 'var config="2 ¦0xcc0000 ¦0xffffff ¦50 ¦0xffffff ¦0xff9900 ¦0xff3300";'
last = last + 'var files="GG/1.jpg ¦GG/2.jpg ¦GG/3.jpg";'
last = last + 'var links="# ¦# ¦# ¦# ¦#" ;var texts=" ¦ ¦ ¦ ¦ ¦" ;'
last = last + 'var so = new SWFObject("js/flashad.swf", "mymovie", swf_width, swf_height, "8");'
last = last + 'so.addVariable("bcastr_flie", files);'
last = last + 'so.addVariable("bcastr_link", links);'
last = last + 'so.addVariable("bcastr_title", texts);'
last = last + 'so.addVariable("config", config);'
last = last + 'so.write("flashad");'
last = last + ' </script>'
last = last + ' </div>'
document.write(last);如果不行的话,把上面的js代码写成一个函数,onload的时候运行。
var __count__ = 0;
lajax.getXmlHttp = function(){
var xmlHttp = null;
try {
xmlHttp = new XMLHttpRequest();
}
catch (e) {
var progIds = ['MSXML2.XMLHTTP', 'Microsoft.XMLHTTP', 'MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0'];
var success = false;
for (var iterator = 0; (iterator < progIds.length) && (!success); iterator++) {
try {
xmlHttp = new ActiveXObject(progIds[iterator]);
success = true;
}
catch (e) {
}
}
if (!success) {
return null;
}
}
return xmlHttp;
};lajax.sendRequest = function(method,url,requestData,onSuccess,onFailure)
{
var xmlHttp = lajax.getXmlHttp();
xmlHttp.open(method,url,true);
if (method=="POST") xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
if(onSuccess != null) {
onSuccess(xmlHttp);
}
} else {
if(!onFailure == null) {
onFailure(xmlHttp);
}
}
}
}
if (method=="POST") xmlHttp.send(requestData);
else xmlHttp.send(null);
}
lajax.loadJS = function(jsPath, callBack) {
var _callBack = function(xmlHttp) {
__count__++;
_includeJS("js" + __count__, xmlHttp.responseText);
callBack();
}
lajax.sendRequest('GET',jsPath, null, _callBack, null);
}function _includeJS(sId, source) {
if (( source != null ) && (!document.getElementById(sId))){
var oHead = document.getElementsByTagName('HEAD').item(0);
var oScript = document.createElement( "script" );
oScript.language = "javascript";
oScript.type = "text/javascript";
oScript.id = sId;
oScript.defer = true;
oScript.text = source;
oHead.appendChild(oScript);
}
}