广告代码静态化js通用函数


Posted in Javascript onMay 09, 2007

/*
JavaScript Document
广告代码静态化js通用函数
原则上每个页面不应该出现域名的固定指向
*/
/*
Config
*/
var sSiteUrl = "http://www.spvjoy.com";
//var sSiteUrl = "http://192.168.1.30:82";
var sSendSite = "http://send.mmstoon.com";
var sMp3Url = "http://r01.mmstoon.com/mp3/";
var sRingUrl = "http://r01.mmstoon.com/ring/";
var sSpUrl = "http://r01.mmstoon.com";
var sMmfUrl = "http://r01.mmstoon.com/MmfRing/";
var sPhotoUrl = "http://p01.mmstoon.com/mmsimg/comm/";
var sVideoPicUrl = "http://r01.mmstoon.com/video/";
//var ServerUrl="http://search.mmstoon.com/netServer/";
//var ServerUrl="http://192.168.1.30/netServer/";
var ServerUrl="http://221.238.249.17/netServer/";

/*
函数功能:从URL得到指定参数的值
*/
function GetUrlArg(strArg, strUrl) {
    var _url;
    if(typeof(strUrl)=="undefined")
        _url = location.href + "&";
    else
        _url = strUrl + "&";
    var regex = new RegExp("(\\?|\\&)" + strArg + "=([^\\&\\?]*)\\&", "gi");
    if (! regex.test(_url)) return "";
    var arr = regex.exec(_url);
    return (RegExp.$2);
}

function urlQuery(){
    var sq = "";
    for(i=0; i<arguments.length(); i++){
        if(sq!="") sq = sq += "&";
        sq += arguments[i] + "=" + GetUrlArg(arguments[i]);
    }    
    return sq;
}

/*
全局变量
*/
var f = GetUrlArg("f");
var lower_cooid = GetUrlArg("lower_cooid");
var adfcid = GetUrlArg("adfcid"); //老二线lower_cooid参数转义 
var ad_id = GetUrlArg("ad_id");
var s = GetUrlArg("s");
var num = GetUrlArg("num");
var ty = GetUrlArg("ty");
var d = GetUrlArg("d");
if (ty=="")
{
    ty="mp3";
}
if(lower_cooid=="" && adfcid!="") lower_cooid = adfcid;

/*
打开链接通用函数,不需要带参数,特殊情况,正常情况下不建议使用
*/
function openCommonWin( url ){
    //主要参数整理
    var sf = GetUrlArg("f", url)
    var slower_cooid = GetUrlArg("lower_cooid", url)
    var sad_id = GetUrlArg("ad_id", url)
    if(sf=="") sf = f;
    if(slower_cooid=="") slower_cooid = lower_cooid;
    if(sad_id=="") sad_id = ad_id;
    if(url.substring(0,"http://un.mmstoon.com".length)=="http://un.mmstoon.com"){
        openUn();
    }else{
        var sUrl = url.split("?")[0] + "?f="+ sf +"&lower_cooid="+ slower_cooid +"&ad_id="+ sad_id +"&d="+ d ;
        if(url.split("?")[1]!=null) sUrl = sUrl + "&" + url.split("?")[1]
        /*例外处理*/
        if (window.location.href.indexOf("/MSNcode/")>0){
            window.open( sUrl,"_self");
        }else{
            window.open( sUrl,"_blank");
        }
    }
}

/*
打开首页
*/
function openHome(){
    if (window.location.href.indexOf("/blue/")>0){
        window.open( "http://www.spjoy.com/AdFiles/blue/blue.htm?f="+ f +"&lower_cooid="+ lower_cooid +"&ad_id="+ ad_id +"&d="+ d, '_blank');
    }else{
        window.open( sSiteUrl + "?f="+ f +"&lower_cooid="+ lower_cooid +"&ad_id="+ ad_id +"&d="+ d, '_blank');
    }
}

/*
打开联盟
*/
function openUn(){
    //联盟转向,照顾二级联盟
    if(f=="98213")
    {
        window.open( "http://union.00yes.com/", '_blank');
    }
    else
    {
        window.open( "http://un.mmstoon.com/?f="+ f, '_blank');
    }
}

/*
打开专题页汇总
*/
function openSpecial(){
    var ips = 36;
    window.open( sSiteUrl + "/ncList.htm?f="+ f +"&lower_cooid="+ lower_cooid +"&ad_id="+ ad_id +"&ty=special&ps=" + ips +"&d="+ d, '_blank');
    //window.location.href = sSiteUrl + "/ncList.htm?f="+ f +"&lower_cooid="+ lower_cooid +"&ad_id="+ ad_id +"&ty=special&ps=" + ips;
}

/*
打开搜索页
*/
function openSearch(){
    window.open( sSiteUrl + "/search.htm?f="+ f +"&lower_cooid="+ lower_cooid +"&ad_id="+ ad_id +"&d="+ d, '_blank');
    //window.location.href = sSiteUrl + "/search.htm?f="+ f +"&lower_cooid="+ lower_cooid +"&ad_id="+ ad_id;
}

/*
打开彩信diy页
*/
function openDiy(){
    window.open( sSiteUrl + "/zyzse.htm?f="+ f +"&lower_cooid="+ lower_cooid +"&ad_id="+ ad_id +"&d="+ d, '_blank');
}

/*
在新窗口打开链接
*/
function openSendWin( ty, num ){
    if(ty=="") ty = "mp3";
    //window.open(sSendSite + "/Send/SendRedirect.asp?f="+ f +"&lower_cooid="+ lower_cooid +"&ad_id="+ ad_id +"&num="+ num +"&ty="+ ty,'_blank','left=100,top=0,width=100,height=100,status=yes,resizable=yes');
    window.open(sSendSite + "/Send/SendRedirect.asp?f="+ f +"&lower_cooid="+ lower_cooid +"&ad_id="+ ad_id +"&num="+ num +"&ty="+ ty +"&d="+ d,'_blank');
    //window.showModalDialog( sSendSite + "/Send/SendRedirect.asp?f="+ f +"&lower_cooid="+ lower_cooid +"&ad_id="+ ad_id +"&num="+ num +"&ty="+ ty,'_blank','dialogWidth:432px;dialogHeight:400px;center:yes;status:0;help:0;edge:raised;resizable:1;scroll:1');
}

/*
在iframe中打开链接
*/
function openSendWinInIfr( ty, num, sSubject, sReviewFile){
    window.open( sSendSite + "/Send/SendFalse.asp?f="+ f +"&lower_cooid="+ lower_cooid +"&ad_id="+ ad_id +"&num="+ num +"&ty="+ ty + "&subject="+ sSubject +"&u="+ sReviewFile +"&d="+ d,'winSend');
}

/*
打开歌手专辑页通用函数,这里可以改变默认资源类型
*/
function openSongerWin( strSonger, ty ){
    var sty="mp3";
    if(typeof(ty)!="undefined") sty = ty
    window.open( sSiteUrl + "/searchResult.htm?f="+ f +"&lower_cooid="+ lower_cooid +"&ad_id="+ ad_id +"&search=" + strSonger +"&ty=" + sty +"&d="+ d, '_spvsearch');
}

/*
打开和弦栏目列表
*/
function openChnChordWin( chn ){
    openChnList( "ring", chn );
}

/*
打开Mp3栏目列表
*/
function openChnMp3Win( chn ){
    //openChnList( "mp3", chn );
    openChnList( "spring", chn );
}

/*
打开特效栏目列表
*/
function openChnSpWin( chn ){
    openChnList( "spring", chn );
}

/*
打开MMF特效栏目列表
*/
function openChnMmfWin( chn ){
    openChnList( "mmf", chn );
}

/*
打开彩信栏目列表
*/
function openPicWin( chn ){
    openChnList( "photo", chn );
}

/*
打开精美彩图栏目列表
*/
function openPicsWin( chn ){
    openChnList( "photo", chn );
}

/*
在框架中打开栏目列表
*/
function openListWin( chn ){
    var sCurUrl = window.location.href;
    var sQuery = "f="+ f +"&lower_cooid="+ lower_cooid +"&ad_id="+ ad_id +"&ty="+ ty +"&chn="+ chn +"&ps="+ ps +"&d="+ d ;
    /*网页模版分流*/
    if (sCurUrl.indexOf("/blue/")>0){
        switch(ty){
            case "photo":
                window.open( sSiteUrl + "/blue/plist.htm?" + sQuery, 'ifrList');
                break;
            case "video":
                window.open( sSiteUrl + "/blue/vlist.htm?" + sQuery, 'ifrList');
                break;
            case "ivr":
                window.open( sSiteUrl + "/blue/ilist.htm?" + sQuery, 'ifrList');
                break;
            default:
                window.open( sSiteUrl + "/blue/mlist.htm?" + sQuery, 'ifrList');
                break;
        }
    }else{
        window.open( sSiteUrl + "/list.htm?" + sQuery, 'ifrList');
    }
}

function openChnList( ty, chn ){
    var schn="";
    var ips = 92;
    if( ty == "photo" || ty == "video" ) ips=16;
    if(typeof(chn)!="undefined") schn = chn;
    var sCurUrl = window.location.href;
    /*网页模版分流*/
    if (sCurUrl.indexOf("/blue/")>0){
        ips = 36;
        if( ty == "photo" || ty == "video" ) ips=16;
        //location.replace( sSiteUrl + "/blue/" + ty + ".htm?f="+ f +"&lower_cooid="+ lower_cooid +"&ad_id="+ ad_id +"&ty="+ ty +"&chn="+ schn +"&ps="+ ips);
        window.open( sSiteUrl + "/blue/" + ty + ".htm?f="+ f +"&lower_cooid="+ lower_cooid +"&ad_id="+ ad_id +"&ty="+ ty +"&chn="+ schn +"&ps="+ ips +"&d="+ d, '_spvchn');
    }
    else
        window.open( sSiteUrl + "/cList.htm?f="+ f +"&lower_cooid="+ lower_cooid +"&ad_id="+ ad_id +"&ty="+ ty +"&chn="+ schn +"&ps="+ ips +"&d="+ d , '_spvchn');
}
/*
搜索窗体提交
*/
var des="请输入歌手或歌名";
function cf(e){if(e.value==des){e.value="";e.select();}}
function cl(e){if(e.value.replace(/ /g,"").replace(/ /g,"")==''){e.value=des;}}

function searchSubmit(e){
    try{
    if(e.nodeName.toLowerCase()=="input")
        e=e.parentElement.previousSibling.firstChild;

    if(e.value==des||e.value.replace(/ /g,"")==''){
        e.select();
        return false;
    }
    else
        window.open( sSiteUrl + "/searchResult.htm?f="+ f +"&lower_cooid="+ lower_cooid +"&ad_id="+ ad_id +"&search="+ e.value +"&d="+ d , '_spvsearch');
        //window.location.href= sSiteUrl + "/searchResult.htm?f="+ f +"&lower_cooid="+ lower_cooid +"&ad_id="+ ad_id +"&search="+ e.value;
    }catch(ee)
    {
        //alert(ee);
    }
}

/*
当页面加载完成之后事件处理
*/
function funcOnload(){
    var oIfr = document.all("winSend");
    if( oIfr != null ){
        oIfr.src = sSendSite + "/send/SendSearchM.asp?f="+ f +"&lower_cooid="+ lower_cooid +"&ad_id="+ ad_id +"&l=1&s="+ s +"&num="+ num +"&d="+ d
    }
    /*
    使XX得到焦点
    */
    //var oTxtSearch = document.all("search");
    //if(oTxtSearch!=null){
    //    oTxtSearch.focus();
    //}else{
    //    var oLink = document.getElementsByTagName("a");
    //    if(oLink.length>0){
    //        oLink[0].focus();
    //    }
    //}
}
window.attachEvent("onload",funcOnload);

/*
页面统计写入
*/
function PvStat(){
    var ty = GetUrlArg("ty");
    document.write("<img width=0 height=0 src='http://ping.mmstoon.com/adPV.htm?f="+ f +"&lower_cooid="+ lower_cooid +"&ad_id="+ ad_id +"&send_type=1&ty="+ ty +"&num="+ num +"&showpage=1' style='display:none'>");
}

/*
搜索关键字统计写入
*/
function SearchKeyStat(strKey){
    var ty = GetUrlArg("ty");
    var sKey;
    if(typeof(strKey)!="undefined"){
        sKey = strKey;
    }
    else{
        sKey = GetUrlArg("search");
    }
    document.write("<img width=0 height=0 src='"+ ServerUrl +"SearchKeyStat.aspx?search="+ sKey +"&ty="+ ty +"&f="+ f +"&lower_cooid="+ lower_cooid +"&ad_id="+ ad_id +"&referrer="+ escape(document.referrer) +"&url="+ escape(location.href) +"' style='display:none'>");
}

function wrLoading(){
    try{
        var oBody = window.document.body;
        var iTop = 250;
        var iLeft = 400;
        if( oBody != null ) {
            iTop = oBody.clientHeight/2 - 20;
            iLeft = oBody.clientWidth/2 - 75;
        }
        /*
        var strDiv = "<div align='center' id='loading' style='Z-INDEX: 1;POSITION: absolute;top:"+ iTop +";left:"+ iLeft +"'>";
            strDiv += "<TABLE border='0' width='150' cellpadding='0' cellspacing='1' bgcolor='#9CC053'><TR>";
            strDiv += "<TD align='center' bgcolor='#ffffff' height='30'>";
            strDiv += "<marquee width='150' height='18' class='TbCate' id='Perday' SCROLLDELAY=150 direction='left'>";
            strDiv += "<img src='../images/dog.gif' heigh=18>数据加载中,请稍等......<img src='../images/dog.gif' heigh=18> 累死人了.....";
            strDiv += "</marquee>";
            strDiv += "</TD></TR></TABLE></div>";
        */
        var strDiv = "<div align='center' id='loading' style='Z-INDEX: 1;POSITION: absolute;top:"+ iTop +";left:"+ iLeft +"'>";
            strDiv += "<TABLE border='0' width='150' cellpadding='0' cellspacing='1' bgcolor='#9CC053'><TR>";
            strDiv += "<TD align='center' bgcolor='#ffffff' height='30'>";
            strDiv += "数据加载中,请稍等......";
            strDiv += "</TD></TR></TABLE></div>";
        document.write(strDiv);
    }catch(e){
        alert(e.description);
    }
}
//wrLoading();
function hideLoading(){
    if(typeof(loading)!="undefined")
        loading.style.display="none";
}
//window.attachEvent("onload", hideLoading); 

/*写一个logo
function writeLogo(){
    var iTop = document.body.scrollHeight - 45;
    var oDiv=document.createElement("<div align='center' id='DivLogo' style='Z-INDEX: 1;POSITION: absolute;top:"+ iTop +";left:0'></div>");
    document.body.appendChild(oDiv);
    document.all("DivLogo").innerHTML = "<img src='http://i01.mmstoon.com/spjoy/AdFiles/images_other/logo_old.gif' width='150' height='45' alt='http://i01.mmstoon.com/spjoy/AdFiles/images_other/logo_old.gif' />"
}
if(f==117215 && window.location.href.indexOf("/FullChannel2/")>0){
    window.attachEvent("onload", writeLogo);
}
*/
/*
**********************视频代码跳转****************************Begin
if(location.href.substring(0,"http://www.spjoy.com/AdFiles/sp760-300/sp760-300.htm".length)=="http://www.spjoy.com/AdFiles/sp760-300/sp760-300.htm")
{
    location.href = "http://www.spjoy.com/AdFiles/760-300-1/760-300-1.htm?" + location.href.split("?")[1];
}

if(location.href.substring(0,"http://www.spjoy.com/AdFiles/sp760-80/760-80.htm".length)=="http://www.spjoy.com/AdFiles/sp760-80/760-80.htm")
{
    location.href = "http://www.spjoy.com/AdFiles/760-80-3/760-80-3.htm?" + location.href.split("?")[1];
}
**********************视频代码跳转****************************End
*/
/*
**********************部分代码跳转到IVR***********************Begin

if(location.href.substring(0,"http://www.spjoy.com/AdFiles/300-300-6/300-300-6.htm".length)=="http://www.spjoy.com/AdFiles/300-300-6/300-300-6.htm")
{
    location.replace("http://www.spjoy.com/AdFiles/ivr300-300/ivr300-300.htm?" + location.href.split("?")[1]);
}

if(location.href.substring(0,"http://www.spjoy.com/AdFiles/468-60-3/468-60-3.htm".length)=="http://www.spjoy.com/AdFiles/468-60-3/468-60-3.htm")
{
    location.replace("http://www.spjoy.com/AdFiles/ivr468-60/ivr468-60.htm?" + location.href.split("?")[1]);
}

if(location.href.substring(0,"http://www.spjoy.com/AdFiles/DJ760-90/dj760-90.htm".length)=="http://www.spjoy.com/AdFiles/DJ760-90/dj760-90.htm")
{
    location.replace("http://www.spjoy.com/AdFiles/ivr760-90/ivr760-90.htm?" + location.href.split("?")[1]);
}

if(location.href.substring(0,"http://www.spjoy.com/AdFiles/468-95-2/468-95-2.htm".length)=="http://www.spjoy.com/AdFiles/468-95-2/468-95-2.htm")
{
    location.replace("http://www.spjoy.com/AdFiles/ivr468-95/ivr468-95.htm?" + location.href.split("?")[1]);
}

if(location.href.substring(0,"http://www.spjoy.com/AdFiles/650-70-2/650-70-2.htm".length)=="http://www.spjoy.com/AdFiles/650-70-2/650-70-2.htm")
{
    location.replace("http://www.spjoy.com/AdFiles/ivr650-70/ivr650-70.htm?" + location.href.split("?")[1]);
}
**********************部分代码跳转到IVR****************************End
*/

Javascript 相关文章推荐
jQuery点击tr实现checkbox选中的方法
Mar 19 Javascript
JavaScript包装对象使用介绍
Aug 29 Javascript
iframe子父页面调用js函数示例
Nov 07 Javascript
jQuery 获取兄弟元素的几种不错方法
May 23 Javascript
AngularJS快速入门
Apr 02 Javascript
将页面table内容与样式另存成excel文件的方法
Aug 05 Javascript
jQuery动态创建元素以及追加节点的实现方法
Oct 20 Javascript
vue-router路由简单案例介绍
Feb 21 Javascript
详解vue.js下引入百度地图jsApi的两种方法
Jul 27 Javascript
element-ui中select组件绑定值改变,触发change事件方法
Aug 24 Javascript
node命令行工具之实现项目工程自动初始化的标准流程
Aug 12 Javascript
JS事件流与事件处理程序实例分析
Aug 16 Javascript
用javascript实现自定义标签
May 08 #Javascript
javascript之对系统的toFixed()方法的修正
May 08 #Javascript
javascript之大字符串的连接的StringBuffer 类
May 08 #Javascript
Javascript中的数学函数集合
May 08 #Javascript
简单的无缝滚动程序-仅几行代码
May 08 #Javascript
JavaScript多线程的实现方法
May 08 #Javascript
(转载)JavaScript中匿名函数,函数直接量和闭包
May 08 #Javascript
You might like
通过5个php实例细致说明传值与传引用的区别
2012/08/08 PHP
深入讲解PHP的对象注入(Object Injection)
2017/03/01 PHP
自动完成JS类(纯JS, Ajax模式)
2009/03/12 Javascript
Javascript 读书笔记索引贴
2010/01/11 Javascript
js页面跳转的问题(跳转到父页面、最外层页面、本页面)
2013/08/14 Javascript
解析Javascript中大括号“{}”的多义性
2013/12/02 Javascript
JQuery实现绚丽的横向下拉菜单
2013/12/19 Javascript
通过复制Table生成word和excel的javascript代码
2014/01/20 Javascript
js实现日期级联效果
2014/01/23 Javascript
JQuery.get提交页面不跳转的解决方法
2015/01/13 Javascript
AngularJS 模型详细介绍及实例代码
2016/07/27 Javascript
javascript数据类型详解
2017/02/07 Javascript
你可能不知道的JSON.stringify()详解
2017/08/17 Javascript
vue vuex vue-rouert后台项目——权限路由(适合初学)
2017/12/29 Javascript
浅谈在vue中用webpack打包之后运行文件的问题以及相关配置方法
2018/02/21 Javascript
vue生成文件本地打开查看效果的实例
2018/09/06 Javascript
[01:29:46]DOTA2上海特级锦标赛C组资格赛#1 OG VS LGD第二局
2016/02/27 DOTA
Python中用于转换字母为小写的lower()方法使用简介
2015/05/19 Python
Python中文分词实现方法(安装pymmseg)
2016/06/14 Python
Python实现类的创建与使用方法示例
2017/07/25 Python
Flask框架URL管理操作示例【基于@app.route】
2018/07/23 Python
在python中利用KNN实现对iris进行分类的方法
2018/12/11 Python
python Pexpect 实现输密码 scp 拷贝的方法
2019/01/03 Python
TFRecord格式存储数据与队列读取实例
2020/01/21 Python
Python networkx包的实现
2020/02/14 Python
Python 从attribute到property详解
2020/03/05 Python
python打包多类型文件的操作方法
2020/09/21 Python
Tiqets荷兰:出售欧洲最美丽的景点和博物馆门票
2018/01/09 全球购物
夏威夷灵感服装及配饰:Reyn Spooner
2018/09/18 全球购物
工商管理专业应届生求职信
2013/11/04 职场文书
十岁生日同学答谢词
2014/01/19 职场文书
公司门卫的岗位职责
2014/02/19 职场文书
经理任命书模板
2014/06/06 职场文书
“5.12”护士节主持词
2015/07/04 职场文书
小学六年级班主任工作经验交流材料
2015/11/02 职场文书
图神经网络GNN算法
2022/05/11 Python