用js 文件导入方式放GG广告

 更新时间:2016年9月20日 19:06  点击:2074

昨天自己的站要放GG AD了,但网站全是静态页面,但我想随便更新GG AD 所以就想到用js文件导入方式,也可以用.php文件导入方式做的,下面来讲讲我的方法:

先来看看,直接在源码中放GG AD很多人都这样放:

<script type="text/javascript"><!--
      google_ad_client = "pub-6219414158063594";
      /* 468x15, 创建于 08-3-10 */
      google_ad_slot = "2571270205";
      google_ad_width = 368;
      google_ad_height = 20;
      //-->
      </script>
      <script type="text/javascript"
      src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
     </script>

这样做有一个很大的不方便之处就是我更换不方便,下面我们来看看用js.文件导入形式.

我在网页源代码中放<script src='/gg_ad/gg.js'></script>

在gg.js文件中放入上面的代码,但因为是js文件所以我们就得去了不必要的符号,代码如下:

google_ad_client = "pub-6219414158063594";
google_ad_slot = "7794600866";
google_ad_width = 234;
google_ad_height = 60;
google_cpa_choice = "";

document.write('<script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>');

还有一种就是有js入导php文件,看例:

<script src='js.php'></script>在js.php里面这样写,

document.write('google_ad_client = "pub-6219414158063594";');其它的写法一样这里就不多说了.

注明:原创www.111cn.net,转载请注明原处.

在HTML网页中使用js获取参数。
我们知道HTML页面是在客户端执行的,这样要获取参数必须使用客户端脚本(如Javascript),在这点上不同于服务器端脚本获取参数方式。
下面的这段js代码获取HTML网页形如"test.html?foo=mytest&program=flash" "?"后所有参数。

<script language=javascript>
<!--
var hrefstr,pos,parastr;
hrefstr = window.location.href;
pos = hrefstr.indexOf("?");
parastr = hrefstr.substring(pos+1);
if (pos>0){
document.write("所有参数:"+parastr);
} else {
document.write("无参数");
}
//-->
</script>



下面的这段js代码则可以更加细化获取HTML网页某一参数

<script language=javascript>
<!--
function getparastr(strname) {
var hrefstr,pos,parastr,para,tempstr;
hrefstr = window.location.href;
pos = hrefstr.indexOf("?")
parastr = hrefstr.substring(pos+1);

para = parastr.split("&");
tempstr="";
for(i=0;i<para.length;i++)
{
tempstr = para[i];
pos = tempstr.indexOf("=");
if(tempstr.substring(0,pos) == strname) {
return tempstr.substring(pos+1);
}
}
return null;
}
// 获取program参数
var programstr = getparastr("program");
document.write(programstr);
//-->
</script>

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>后台管理首页</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312"><LINK
href="../styles/admin_style.css" type=text/css rel=stylesheet>
<SCRIPT src="ymPrompt.js" type=text/javascript></SCRIPT>

<SCRIPT language=javascript>
<!--
function menu_tree(meval)
{
  var left_n=eval(meval);
  if (left_n.style.display=="none")
  { eval(meval+".style.display='';"); }
  else
  { eval(meval+".style.display='none';"); }
}
var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
//extra height in px to add to iframe in FireFox 1.0+ browsers
var FFextraHeight=getFFVersion>=0.1? 16 : 0

function dyniframesize(iframename) {
  var pTar = null;
  if (document.getElementById){
    pTar = document.getElementById(iframename);
  }
  else{
    eval('pTar = ' + iframename + ';');
  }
  if (pTar && !window.opera){
    //begin resizing iframe
    pTar.style.display="block"
   
    if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight){
      //ns6 syntax
      pTar.height = pTar.contentDocument.body.offsetHeight+FFextraHeight;
    }
    else if (pTar.Document && pTar.Document.body.scrollHeight){
      //ie5+ syntax
      pTar.height = pTar.Document.body.scrollHeight;
    }
  }
}
-->
</SCRIPT>
</HEAD>
<BODY>
<DIV id=body>
<DIV id=top>
<TABLE height=52 cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD bgColor=#014e82 height=13>&nbsp;</TD></TR>
<TR>
<TD bgColor=#014e82 height=21>
<TABLE id=menu_top borderColor=#ededed cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR>
<TD borderColor=#ededed
bgColor=#ffffff>&nbsp;后台管理</TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD bgColor=#9eb9cc>
<TABLE id=menu_little>
<TBODY>
<TR>
<TD></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV>
<DIV id=center>
<DIV id=menu>
<TABLE class=menu id=menu cellSpacing=5>
<TBODY>
<TR>
<TD class=menu_td onclick="javascript:menu_tree('left_1');" bgColor=#ffff99
height=24><STRONG>&nbsp;基本管理</STRONG></TD></TR>
<TR>
<TD>
<TABLE class=menu_2 id=left_1 style="DISPLAY: none">
<TBODY>
<TR>
<TD>
<LI><A href="index.php">后台首页</A></LI></TD></TR>
<TR>
<TD>
<LI>退出后台</LI></TD></TR>
<TR>
<TD>
<LI>管理员设置</LI></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD class=menu_td onclick="javascript:menu_tree('left_2');" bgColor=#ffff99
height=24><STRONG>&nbsp;文章管理</STRONG></TD></TR>
<TR>
<TD>
<TABLE class=menu_2 id=left_2 style="DISPLAY: none">
<TBODY>
<TR>
<TD>
<LI><A href="article/article_add.php" target=mainFrame>发表文章</A></LI></TD></TR>
<TR>
<TD>
<LI><A href="article/article_list.php" target=mainFrame>管理文章</A></LI></TD></TR>
<TR>
<TD>
<LI><A href="article/article_sort/article_sort_list.php"
target=mainFrame>管理分类</A></LI></TD></TR>
<TR>
<TD>
<LI>管理评论</LI></TD></TR>
<TR>
<TD>
<LI>管理留言</LI></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD class=menu_td onclick="javascript:menu_tree('left_3');" bgColor=#ffff99
height=24><STRONG>&nbsp;XXXXX</STRONG></TD></TR>
<TR>
<TD>
<TABLE class=menu_2 id=left_3 style="DISPLAY: none">
<TBODY>
<TR>
<TD>
<LI><A href="">xxxxx</A></LI></TD></TR>
<TR>
<TD>
<LI><A href="">xxx</A></LI></TD></TR>
<TR>
<TD>
<LI><A href="">xxxx</A></LI></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD class=menu_td onclick="javascript:menu_tree('left_4');" bgColor=#ffff99
height=24><STRONG>&nbsp;XXXXX</STRONG></TD></TR>
<TR>
<TD>
<TABLE class=menu_2 id=left_4 style="DISPLAY: none">
<TBODY>
<TR>
<TD height=24>
<LI><A href="">xxxxx</A></LI></TD></TR>
<TR>
<TD>
<LI><A href="">xxxxx</A></LI></TD></TR>
<TR>
<TD>
<LI><A
href="">xxxxxx</A></LI></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV>
<DIV id=main><IFRAME id=mainFrame style="DISPLAY: block" name=mainFrame
src="main.php" frameBorder=0 scrolling=no
onload="javascript:{dyniframesize('mainFrame');}"
height=48>     您的浏览器不支持此功能,请您使用最新的版本。   </IFRAME></DIV></DIV></DIV></BODY></HTML>

<html>
<head>
</head>
<body>
<marquee behavior="alternate" height="400" direction="up" scrollamount="3" scrolldelay="30" width="500" bgcolor="#3399FF">
<marquee behavior="alternate" height="50" direction="left" scrollamount="3" scrolldelay="30" width="100%">
<font style="font-size: 35px">MARQUEE</font>
</marquee>
</marquee>
</body>
</html>

<html>
<head>
<title>ThreeAnts Player</title>
<base target="_self">
<meta name="author" content="episome">
<meta name="keywords" content="Player,cdf,desktop toy">
</head>
<style>
body{
 border:#0099cc 2px solid;
 background-color:WhiteSmoke;
 margin:5px;
}
body,td{
 font-family:Tahoma,Georgia;
 font-size: 8pt;
 white-space: nowrap;
}
#percent{
 font-size:7pt;
 color:green;
 font-weight: bold;
}
.ctrlBar td{
 filter: Alpha(Opacity=100, FinishOpacity=30, Style=1, StartX=0, StartY=0, FinishX = 0, FinishY = 50);
 font-weight: bold;
 font-size: 7pt;
 color:darkblue;
 border:#0099cc 1px solid;
 background-color:#FFF;
}
A:visited,A:link{
 color:darkblue;
 cursor: hand;
 text-decoration: none;
}
A:hover{
 color:red;
 cursor: hand;
 text-decoration: none;
}
.content td{
 width:100%;
 table-layout: fixed;
 filter: Alpha(Opacity=100, FinishOpacity=40, Style=1, StartX=0, StartY=0, FinishX = 0, FinishY = 50);
 cursor: hand;
 border:#0099cc 1px solid;
 border-top:0px;
 background-color:white;
 height: 24px;
}
.hilite_content td{
 width:100%;
 table-layout: fixed;
 color:red;
 cursor: hand;
 border-right:#0099cc 1px solid;
 border-left:#0099cc 1px solid;
 border-bottom:#0099cc 1px solid;
 background-color:#ddedfb;
 height: 24px;
}
</style>
<script language="JavaScript">
var scrollcount=0;
var dragy;
var scrollarrowtop;
function initdrag() {
 scrollcount=1;
 dragy=event.clientY;
 document.body.setCapture();
}
function startdrag() {
 if (scrollcount==1) {
  window.scrollBy(0,dragy-event.clientY);
  document.body.style.cursor='hand';
  dragy=event.clientY;
 }
}
function enddrag() {
 document.body.style.cursor='';
 scrollcount=0;
 document.body.releaseCapture();
}
</script>
<body
scroll=no
ondragstart = "return false;"
onselect = "return false;"
onselectstart="return false;"
onmousedown="initdrag()"
onmousemove="startdrag()"
onmouseup="enddrag()"
>
<script>
var PlayType = ",wma,wmv,avi,mpg,mpeg,m1v,mp2,wav,mp3"
var nowPlayingID
var lastSelected
var lastPlayed

var si = setInterval("Timer()",1000)
function Timer(){
 percent.innerHTML = Math.round((Player.currentposition/Player.selectionend)*100)+"%"
 ttt.style.width = Math.round((Player.currentposition/Player.selectionend)*100)+"%"
 if((Player.currentposition >= Player.selectionend) && Player.currentposition!=0){
  clearInterval(si)
  playNextMusic()
  si = setInterval("Timer()",1000)
 }
}
function mute(){
 Player.mute = !Player.mute
}
//检测载入的文件类型
function CheckType(){
 var s = FileObj.value.split(".");
 return PlayType.indexOf(s[s.length-1].toLowerCase())>0?true:false;
}
// open
function openMusic(){
  FileObj.click();
  if(FileObj.value != "" && CheckType()){
   FileObj.value.replace("\","\\");
   addMusic(FileObj.value);
   FileObj.value = "";
  }
}
// Add music
function addMusic(musicSrc){
 var newTR=playListTable.insertRow();
 var newTD=newTR.insertCell();
 newTR.className = "content";
 newTR.onclick = function(){
  if (lastSelected != null){
   lastSelected.className = "content"
  }
  this.className = "hilite_content"
  lastSelected = this
 }
 newTD.ondblclick = function(){
  playMusic(this.id)
 }
 newTD.oncontextmenu = function(){
  playListTable.deleteRow(this.parentElement.rowIndex)
 }
 musicTitle = musicSrc.split("\");
 musicTitle = musicTitle[musicTitle.length-1].split(".");
 musicTitle = musicTitle.slice(0,musicTitle.length-1);
 newTD.innerHTML = musicTitle
 newTD.musicName = musicTitle
 newTD.musicSrc  = musicSrc
 newTD.id  = "m" + newTR.rowIndex
}
// play
function playMusic(id,currentposition){
 if (lastPlayed != null){
  lastPlayed.innerHTML = lastPlayed.musicName
 }
 if(!document.all[id]){
  id = "m1"
 }
 TD = eval(id)
 TD.innerHTML += "&nbsp;<a id=percent></a>"
 lastPlayed = TD
 Player.filename = TD.musicSrc
 nowPlayingID = id
 Player.currentposition = (currentposition == undefined) ? 2 : currentposition
}
// play next music
function playNextMusic(){
 Player.stop()
 newID = parseInt(nowPlayingID.replace("m",""))+1
 playMusic("m"+newID)
}
// play prev music
function playPrevMusic(){
 Player.stop()
 newID = parseInt(nowPlayingID.replace("m",""))-1
 playMusic("m"+newID)
}
// cookie
function saveCookie(name,value,days) {
 if (days) {
  var date = new Date();
  date.setTime(date.getTime()+(days*24*60*60*1000))
  var expires = "; expires="+date.toGMTString()
 }
 else expires = ""
 document.cookie = name+"="+value+expires+"; path=/"
}
function readCookie(name) {
 var nameEQ = name + "="
 var ca = document.cookie.split(';')
 for(var i=0;i<ca.length;i++) {
  var c = ca[i];
  while (c.charAt(0)==' ') c = c.substring(1,c.length)
  if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length)
 }
 return null
}
function deleteCookie(name) {
 saveCookie(name,"",-1)
}
// Load play list from Cookie
window.onload = function(){
 cookiePlayList = readCookie("cookiePlayList")
 cookiePlayList = cookiePlayList.split(",");
 for(x in cookiePlayList){
  addMusic(cookiePlayList[x])
 }
 cookieNowPlayingID = readCookie("cookieNowPlayingID")
 cookieCurrentposition = readCookie("cookieCurrentposition")
 playMusic(cookieNowPlayingID,cookieCurrentposition)
}
// Save play list & now playing
window.onunload = function(){
 if(Player.filename!="" && Player.filename!=null){
  saveCookie("cookieNowPlayingID",nowPlayingID,100)
  saveCookie("cookieCurrentposition",Player.currentposition,100)
 }
 var playList = new Array()
 for(i=1;i<playListTable.rows.length;i++){
  playList.push(playListTable.rows[i].cells[0].musicSrc)
 }
 saveCookie("cookiePlayList",playList,100)
}
window.onerror = function(){
 return true;
}
</script>
<table cellpadding="3" cellspacing="0" width='100%' id="playListTable" onselectstart="return false;">
 <tr class="ctrlBar">
  <td>
   <a href="javascript:openMusic()">open</a>
    | <a href="javascript:playPrevMusic()">prev</a>
    | <a href="javascript:Player.play()">play</a>
    | <a href="javascript:Player.pause()">pause</a>
    | <a href="javascript:Player.stop()">stop</a>
    | <a href="javascript:playNextMusic()">next</a>
   <!--  | <a href="javascript:mute()">mute</a> -->
  </td>
 </tr>
</table>
<table cellspacing="1" width='100%' onselectstart="return false;" style="border:#0099cc 1px solid;">
 <tr class="ctrlBar">
  <td id="ttt" style="background-color:black;height:12px;width:1px;"></td>
  <td style="background-color:silver;"></td>
 </tr>
</table>
<object classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" id="Player" width="0" height="0">
 <param name="autoplay" value="1">
</object>
<input type="file" id="FileObj" style="display:none">
</body>
</html>

[!--infotagslink--]

相关文章

  • php读取zip文件(删除文件,提取文件,增加文件)实例

    下面小编来给大家演示几个php操作zip文件的实例,我们可以读取zip包中指定文件与删除zip包中指定文件,下面来给大这介绍一下。 从zip压缩文件中提取文件 代...2016-11-25
  • Jupyter Notebook读取csv文件出现的问题及解决

    这篇文章主要介绍了JupyterNotebook读取csv文件出现的问题及解决,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教...2023-01-06
  • Photoshop打开PSD文件空白怎么解决

    有时我们接受或下载到的PSD文件打开是空白的,那么我们要如何来解决这个 问题了,下面一聚教程小伙伴就为各位介绍Photoshop打开PSD文件空白解决办法。 1、如我们打开...2016-09-14
  • 解决python 使用openpyxl读写大文件的坑

    这篇文章主要介绍了解决python 使用openpyxl读写大文件的坑,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2021-03-13
  • C#实现HTTP下载文件的方法

    这篇文章主要介绍了C#实现HTTP下载文件的方法,包括了HTTP通信的创建、本地文件的写入等,非常具有实用价值,需要的朋友可以参考下...2020-06-25
  • C#操作本地文件及保存文件到数据库的基本方法总结

    C#使用System.IO中的文件操作方法在Windows系统中处理本地文件相当顺手,这里我们还总结了在Oracle中保存文件的方法,嗯,接下来就来看看整理的C#操作本地文件及保存文件到数据库的基本方法总结...2020-06-25
  • SpringBoot实现excel文件生成和下载

    这篇文章主要为大家详细介绍了SpringBoot实现excel文件生成和下载,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2021-02-09
  • php无刷新利用iframe实现页面无刷新上传文件(1/2)

    利用form表单的target属性和iframe 一、上传文件的一个php教程方法。 该方法接受一个$file参数,该参数为从客户端获取的$_files变量,返回重新命名后的文件名,如果上传失...2016-11-25
  • php批量替换内容或指定目录下所有文件内容

    要替换字符串中的内容我们只要利用php相关函数,如strstr,str_replace,正则表达式了,那么我们要替换目录所有文件的内容就需要先遍历目录再打开文件再利用上面讲的函数替...2016-11-25
  • PHP文件上传一些小收获

    又码了一个周末的代码,这次在做一些关于文件上传的东西。(PHP UPLOAD)小有收获项目是一个BT种子列表,用户有权限上传自己的种子,然后配合BT TRACK服务器把种子的信息写出来...2016-11-25
  • Zend studio文件注释模板设置方法

    步骤:Window -> PHP -> Editor -> Templates,这里可以设置(增、删、改、导入等)管理你的模板。新建文件注释、函数注释、代码块等模板的实例新建模板,分别输入Name、Description、Patterna)文件注释Name: 3cfileDescriptio...2013-10-04
  • AI源文件转photoshop图像变模糊问题解决教程

    今天小编在这里就来给photoshop的这一款软件的使用者们来说下AI源文件转photoshop图像变模糊问题的解决教程,各位想知道具体解决方法的使用者们,那么下面就快来跟着小编...2016-09-14
  • C++万能库头文件在vs中的安装步骤(图文)

    这篇文章主要介绍了C++万能库头文件在vs中的安装步骤(图文),文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2021-02-23
  • php文件上传你必须知道的几点

    本篇文章主要说明的是与php文件上传的相关配置的知识点。PHP文件上传功能配置主要涉及php.ini配置文件中的upload_tmp_dir、upload_max_filesize、post_max_size等选项,下面一一说明。打开php.ini配置文件找到File Upl...2015-10-21
  • ant design中upload组件上传大文件,显示进度条进度的实例

    这篇文章主要介绍了ant design中upload组件上传大文件,显示进度条进度的实例,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-10-29
  • C#使用StreamWriter写入文件的方法

    这篇文章主要介绍了C#使用StreamWriter写入文件的方法,涉及C#中StreamWriter类操作文件的相关技巧,需要的朋友可以参考下...2020-06-25
  • php实现文件下载实例分享

    举一个案例:复制代码 代码如下:<?phpclass Downfile { function downserver($file_name){$file_path = "./img/".$file_name;//转码,文件名转为gb2312解决中文乱码$file_name = iconv("utf-8","gb2312",$file_name...2014-06-07
  • C#路径,文件,目录及IO常见操作汇总

    这篇文章主要介绍了C#路径,文件,目录及IO常见操作,较为详细的分析并汇总了C#关于路径,文件,目录及IO常见操作,具有一定参考借鉴价值,需要的朋友可以参考下...2020-06-25
  • 查找php配置文件php.ini所在路径的二种方法

    通常php.ini的位置在:复制代码 代码如下:/etc目录下或/usr/local/lib目录下。如果你还是找不到php.ini或者找到了php.ini修改后不生效(其实是没找对),请使用如下办法:1.新建php文件,写入如下代码复制代码 代码如下:<?phpe...2014-05-31
  • PHP判断上传文件类型的解决办法

    分享给大家php判断上传文件类型的方法,大家一起学习学习。/** * 读取文件前几个字节 判断文件类型 * @return String */ function checkTitle($filename){ $file=fopen($filename, "rb"); $bin=fread($file, 2); /...2015-10-21