博客
 
« 100种增加网站流量的方法我们不是一个简单的web UI »

flash播放前用js加载广告的方法

 整理了一个flash播放前用js加载广告的方法:

准备2个JS 
第一个,控制广告和游戏的顺序,广告在游戏前还后。
复制代码var playShow = "1"; 
function flashStart(srctime){ 
   if (playShow=="1") 
   { 
  showPlay(); 
  setTimeout('setFlash()',srctime*1000); 
   } 
   else 
   { 
  setFlash(); 
   } 

function showPlay() 

     document.write("<scr"+"ipt  language=javascript  src=http://放广告JS的路径/game.js></scr"+"ipt>"); 

function setFlash() 

 str = "<OBJECT ID=\"flashgame\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" "; 
 str += "codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\""+w+"\" height=\""+h+"\">"; 
 str += "<param name=\"movie\"  value=\"" + flashPath + "\">";       
          
 str += "<param name=quality value=high>\n"; 
 str += "<embed src=" + flashPath + " loop=false menu=false quality=high "; 
 str += "height='"+h+"' width='"+w+"' TYPE=application/x-shockwave-flash PLUGINSPAGE=http://www.macromedia.com/shockwave/download/index.cgi?P1_Pro d_Version=ShockwaveFlash type='application/x-shockwave-flash'>"; 
 str += "</OBJECT>"; 
 document.getElementById(flashid).innerHTML = str; 

function PlayInFull(flashUrl) { 
 window.open("http://放全屏游戏页的路径/playinfull.htm?"+flashUrl,"qqhhy","fullscreen"); 
 window.close() 

 


广告的JS自己看着办吧
给个参考,如广告为播放flash
复制代码flashLog = "gamead.swf";
    logw = "600";
    logh = "400";
    document.write ("<OBJECT ID=\"flashgame\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" ");
    document.write ("codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\""+logw+"\" height=\""+logh+"\">\n");
    document.write ("<param name=\"movie\"  value=\"" + flashLog + "\">\n");
    document.write ("<param name=quality value=high>\n");
    document.write ("<embed src=" + flashLog + " loop=false menu=false quality=high ");
    document.write ("height='"+logh+"' width='"+logw+"' TYPE=application/x-shockwave-flash PLUGINSPAGE=http://www.macromedia.com/shockwave/download/index.cgi?P1_Pro d_Version=ShockwaveFlash type='application/x-shockwave-flash'>\n");
    document.write ("</OBJECT>\n");
 

 

下面是那个全屏游戏页面代码playinfull.htm

复制代码<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK"><title>站点名称在线网页flash游戏</title>
</head>
<body bgcolor="#000000" leftmargin="0" topmargin="0" bottommargin="22" scroll="no">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="right" style="padding-top:2px; padding-bottom:2px"><div style="width:50%; float:left; text-align:left; color:#FFFFFF">  站点名称【*******.COM】全屏游戏</div><div style="width:50%; float:right">
<a href='javascript:location.reload();' style="color:ffffff">再玩一次</a>
<a href="javascript:window.close();" style="color:ffffff">关闭本页面</a>  </div>
</td>
</tr>
</table>
<script language=JavaScript>
<!--
var searchString = location.search 
var pos = searchString.indexOf ("?")
flashPath = searchString.substr (1, searchString.length)
document.write ("<OBJECT ID='movie' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width='100%' height='100%'>\n");
document.write ("<PARAM NAME=movie  VALUE=" +  flashPath + ">\n");
document.write ("<PARAM NAME=quality VALUE=high>\n");
document.write ("<embed src=" + flashPath + " loop=false menu=false quality=high height='100%' width='102%' TYPE=application/x-shockwave-flash PLUGINSPAGE=http://www.macromedia.com/shockwave/download/index.cgi?P1_Pro d_Version=ShockwaveFlash type='application/x-shockwave-flash'>\n");
document.write ("</OBJECT>\n");
//-->
</script>
</body>
</html>
 


最后,模板里面需要放的

复制代码<SCRIPT language=javascript>
var w="640";
var h="480";
var wandh = '';
if(wandh!=""){
  var arrWh = wandh.split(",");
  if(arrWh.length>1){
    w=arrWh[0];
    h=arrWh[1];
  }}
</SCRIPT><div class=gflash id=qqhhy>
 <SCRIPT language=javascript>
var flashPath = '{dede:field name="flashurl"/}';<!--如果不是使用flash模型,改成你那个FLASH游戏地址的字段-->
var flashid="qqhhy";
flashStart(4);<!--这里的数字代表游戏前广告播放时间长短,如这里就是4秒-->
      </SCRIPT></div>
<p align=center><A onMouseOver="return true" href="javascript:PlayInFull(flashPath)"><span style="color:#ff0000;text-decoration: none">[全屏玩游戏]</span></A>  <A href="javascript:location.reload();" style="color:#ff0000;text-decoration: none">[再玩一次]</A></p>

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

 
运营中的品牌网站:真人秀节目资讯网 我要出气网
Copyright 2008 © AliCui.com all right reserved. 沪ICP备07002205号 MSN:AliCui@MSN.Com
进入真人秀