|
查看: 1215|回复: 23
|
广告随机播放的疑惑
[复制链接]
|
|
|
请问这里有人可以请教一下吗?
我有一组广告, 我希望每次refresh webpage的时候, 它可以random pick
然后, 我希望有一个很简单方法/系统可以让我, 简单是删除或者增加广告
这些, 是不是怎么做? |
|
|
|
|
|
|
|
|
|
|
发表于 21-4-2009 03:30 PM
|
显示全部楼层
如果你是想一劳永逸的就用 数据库,要不然就做个 xml 之类的。
想要简简单单 copy paste 的就看看 ajax 的教学,网上一堆任你选。
之前做过一个图片效果,蛮ok 的。 看 aviocall[dot]com 顶部。 |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 21-4-2009 03:44 PM
|
显示全部楼层
原帖由 vampcheah 于 21-4-2009 03:30 PM 发表 
如果你是想一劳永逸的就用 数据库,要不然就做个 xml 之类的。
想要简简单单 copy paste 的就看看 ajax 的教学,网上一堆任你选。
之前做过一个图片效果,蛮ok 的。 看 aviocall[dot]com 顶部。
一劳永逸的方法是大概怎么样? 可以解说一下吗? |
|
|
|
|
|
|
|
|
|
|
发表于 21-4-2009 05:24 PM
|
显示全部楼层
用 php/ .net/ js etc 做一个 image loader
使用 数据库 或 xml 等等记录图片地址。 |
|
|
|
|
|
|
|
|
|
|
发表于 22-4-2009 10:03 AM
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|
发表于 22-4-2009 02:56 PM
|
显示全部楼层
<script language="JavaScript">
var j,d="",l="",m="",p="",q="",z="",KW_ARI= new Array()
KW_ARI[KW_ARI.length]='images/image1.jpg'; // <--image location
KW_ARI[KW_ARI.length]='images/image2.png';
KW_ARI[KW_ARI.length]='images/image3.jpg';
KW_ARI[KW_ARI.length]='images/image4.jpg';
j=parseInt(Math.random()*KW_ARI.length);
j=(isNaN(j))?0:j;
document.write("<img src='"+KW_ARI[j]+"'>");
</script>
不懂是不是你要的function. |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 22-4-2009 03:15 PM
|
显示全部楼层
原帖由 klvn 于 22-4-2009 02:56 PM 发表 
var j,d="",l="",m="",p="",q="",z="",KW_ARI= new Array()
KW_ARI[KW_ARI.length]='images/image1.jpg'; //
嗯. 我test 了, 是我要的. 我想要请问, 如果我要为每个banner 加上相应的url 链接,
要怎么加? 麻烦请教一下. |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 22-4-2009 03:17 PM
|
显示全部楼层
原帖由 vampcheah 于 21-4-2009 05:24 PM 发表 
用 php/ .net/ js etc 做一个 image loader
使用 数据库 或 xml 等等记录图片地址。
这个,我不会. 我会再去研究看看. |
|
|
|
|
|
|
|
|
|
|
发表于 22-4-2009 03:35 PM
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 22-4-2009 03:52 PM
|
显示全部楼层
原帖由 keroro小军曹 于 22-4-2009 10:03 AM 发表 
不然就用最原始的方法 用 array 就好了
如果用array, 意思是说, 以后我加减, 都要逐一更改, 是吗? |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 22-4-2009 03:53 PM
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 22-4-2009 04:00 PM
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|
发表于 22-4-2009 04:02 PM
|
显示全部楼层
<script language="JavaScript">
var j,d="",l="",m="",p="",q="",z="",KW_ARI= new Array()
KW_ARI[KW_ARI.length]='/images/image1.jpg?&border=0&link=http://www.link1.com'; //<--Image location with link
KW_ARI[KW_ARI.length]='/images/image2.jpg?&border=0&link=http://www.link2.com'; //<--Image location with link
j=parseInt(Math.random()*KW_ARI.length);
j=(isNaN(j))?0:j;
if (KW_ARI[j].indexOf('?')==-1) {
document.write("<img src='"+KW_ARI[j]+"'>");
}
else {
nvp=KW_ARI[j].substring(KW_ARI[j].indexOf('?')+2).split('&');
for(var i=0;i<nvp.length;i++) {
sub=nvp.split('=');
switch(sub[0]) {
case 'link':
l="<a href='"+unescape(sub[1])+"'>";
p="</a>";
break;
case 'target':
q=" target='"+unescape(sub[1])+"'";
break;
default:
m+=" "+sub[0]+"='"+unescape(sub[1])+"'";
break;
}
}
z=(l!="")?((q!="")?l.substring(0,l.length-1)+q+">":l):"";
z+="<img src='"+KW_ARI[j].substring(0,KW_ARI[j].indexOf('?'))+"'"+m+">"+p;
document.write(z);
}
</script> |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 22-4-2009 08:47 PM
|
显示全部楼层
原帖由 klvn 于 22-4-2009 04:02 PM 发表 
var j,d="",l="",m="",p="",q="",z="",KW_ARI= new Array()
KW_ARI[KW_ARI.length]='/images/image1.jpg?&border=0&link=http://www.link1.com'; //
对了. 另外想要请问, 这个script 是不是不可以放gif, 是吗?
因为我试过如果jpeg 可以load, gif 不会load
不好意思再麻烦 |
|
|
|
|
|
|
|
|
|
|
发表于 22-4-2009 09:10 PM
|
显示全部楼层
回复 12# p!gl@dy 的帖子
其实是一样的
-〉 document.write("<img src='"+KW_ARI[j]+"'>");
只是有点像用javascript来写html code 罢了
你就改成像
document.write('<a href=" 你要的Link "><img tag /></a>');
当然link也是dynamic的啦 |
|
|
|
|
|
|
|
|
|
|
发表于 23-4-2009 10:04 AM
|
显示全部楼层
原帖由 p!gl@dy 于 22-4-2009 08:47 PM 发表 
对了. 另外想要请问, 这个script 是不是不可以放gif, 是吗?
因为我试过如果jpeg 可以load, gif 不会load
不好意思再麻烦
.gif 不会load...
----用这个-------------------------
<script language="JavaScript">
images = new Array(2); //<--total images
images[0] = "<a href = 'http://www.link1.com'><img src='http://www.abc.com/image1.gif' alt='Visit Computer Hope' border='0'></a>";
images[1] = "<a href = 'http://www.link2.com'><img src='http://www.abc.com/image2.gif' alt='Computer History' border='0'></a>";
//images[2] = "<a href = 'http://www.link3.com'><img src='http://www.abc.com/image3.gif' alt='Visit Computer Hope' border='0'></a>";
//images[3] = "<a href = 'http://www.link4.com'><img src='http://www.abc.com/image4.gif' alt='Computer Hope Newsletter' border='0'></a>";
index = Math.floor(Math.random() * images.length);
document.write(images[index]);
</script>
-------------------- |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 23-4-2009 01:52 PM
|
显示全部楼层
原帖由 _cy_ 于 22-4-2009 09:10 PM 发表 
其实是一样的
-〉 document.write("");
只是有点像用javascript来写html code 罢了
你就改成像
document.write('');
当然link也是dynamic的啦
呵呵. 不好意思. 我是对这些都很笨. 真的谢谢你的指教.
原帖由 klvn 于 23-4-2009 10:04 AM 发表 
.gif 不会load...
----用这个-------------------------
images = new Array(2); //
嗯嗯. 好的的. 我再试试看再回来报告. 真的
谢谢你的不厌其烦. |
|
|
|
|
|
|
|
|
|
|
发表于 23-4-2009 05:59 PM
|
显示全部楼层
不谢。。
以前我刚学programming 的时候。。
也面对同样的问题。。。 |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 24-4-2009 09:00 PM
|
显示全部楼层
原帖由 klvn 于 23-4-2009 05:59 PM 发表 
不谢。。
以前我刚学programming 的时候。。
也面对同样的问题。。。
我试了, 可以了. 谢谢了
我还有一个问题, 我想要做一个往滚动的文字条码
是不是要用 marquee? |
|
|
|
|
|
|
|
|
|
|
发表于 24-4-2009 10:03 PM
|
显示全部楼层
|
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|