ecshop 放入购物车 简单美化
时间:2024年01月31日
/来源:网络
/编辑:佚名
一:把如下函数代码加入到common.js 最末尾
复制代码
/* *
* 点击购物后弹出提示层
* Chen 2010.7.28
* 参数 cartinfo:购物车信息
*/function openDiv_chen(cartinfo)
{
var _id = "speDiv";
var m = "mask";
if (docEle(_id)) document.removeChild(docEle(_id));
if (docEle(m)) document.removeChild(docEle(m));
//计算上卷元素值
var scrollPos;
if (typeof window.pageYOffset != 'undefined')
{
scrollPos = window.pageYOffset;
}
else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat')
{
scrollPos = document.documentElement.scrollTop;
}
else if (typeof document.body != 'undefined')
{
scrollPos = document.body.scrollTop;
}
var i = 0;
var sel_obj = document.getElementsByTagName('select');
while (sel_obj[i])
{
sel_obj[i].style.visibility = "hidden";
i++;
}
// 新激活图层
var newDiv = document.createElement("div");
newDiv.id = _id;
newDiv.style.position = "absolute";
newDiv.style.zIndex = "10000";
newDiv.style.width = "350px";
newDiv.style.height = "100px";
newDiv.style.top = (parseInt(scrollPos + 400)) + "px";
newDiv.style.left = (parseInt(document.body.offsetWidth) - 200) / 2 + "px"; // 屏幕居中
newDiv.style.overflow = "auto";
newDiv.style.background = "#FFF";
newDiv.style.border = "3px solid #59B0FF";
newDiv.style.padding = "5px";
//生成层内内容
newDiv.innerHTML = '<h4 style="font-size:14; margin:15 0 0 15;">' + "商品成功放入购物车 [<a href='javascript:cancel_div()' class='f6' >" + '关闭' + "</a>]<br><br>"+ cartinfo + "</h4>";
newDiv.innerHTML += "<br /><center><a href='http://caihong19870228.blog.163.com/blog/flow.php'>进入购物车</a> <a [<a href='javascript:cancel_div()'>继续购物</a></center>";
document.body.appendChild(newDiv);
// mask图层
var newMask = document.createElement("div");
newMask.id = m;
newMask.style.position = "absolute";
newMask.style.zIndex = "9999";
newMask.style.width = document.body.scrollWidth + "px";
newMask.style.height = document.body.scrollHeight + "px";
newMask.style.top = "0px";
newMask.style.left = "0px";
newMask.style.background = "#FFF";
newMask.style.filter = "alpha(opacity=30)";
newMask.style.opacity = "0.40";
document.body.appendChild(newMask);
}
///////////////////////////////////////////
复制代码
二、再继续在 common.js 找到如下代码
复制代码
switch(result.confirm_type)
{
case '1' :
if (confirm(result.message)) location.href = cart_url;
break;
case '2' :
if (!confirm(result.message)) location.href = cart_url;
break;
case '3' :
location.href = cart_url;
break;
default :
break;
}
复制代码
修改成如下代码
复制代码
switch(result.confirm_type)
{
case '1' :
//if (confirm(result.message)) location.href = cart_url;
openDiv_chen(result.content)//将购物车信息作为参数传入
break;
case '2' :
//if (!confirm(result.message)) location.href = cart_url;
openDiv_chen(result.content)
break;
case '3' :
//location.href = cart_url;
openDiv_chen(result.content)
break;
default :
break;
}
复制代码
这样就可以了。
复制代码
/* *
* 点击购物后弹出提示层
* Chen 2010.7.28
* 参数 cartinfo:购物车信息
*/function openDiv_chen(cartinfo)
{
var _id = "speDiv";
var m = "mask";
if (docEle(_id)) document.removeChild(docEle(_id));
if (docEle(m)) document.removeChild(docEle(m));
//计算上卷元素值
var scrollPos;
if (typeof window.pageYOffset != 'undefined')
{
scrollPos = window.pageYOffset;
}
else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat')
{
scrollPos = document.documentElement.scrollTop;
}
else if (typeof document.body != 'undefined')
{
scrollPos = document.body.scrollTop;
}
var i = 0;
var sel_obj = document.getElementsByTagName('select');
while (sel_obj[i])
{
sel_obj[i].style.visibility = "hidden";
i++;
}
// 新激活图层
var newDiv = document.createElement("div");
newDiv.id = _id;
newDiv.style.position = "absolute";
newDiv.style.zIndex = "10000";
newDiv.style.width = "350px";
newDiv.style.height = "100px";
newDiv.style.top = (parseInt(scrollPos + 400)) + "px";
newDiv.style.left = (parseInt(document.body.offsetWidth) - 200) / 2 + "px"; // 屏幕居中
newDiv.style.overflow = "auto";
newDiv.style.background = "#FFF";
newDiv.style.border = "3px solid #59B0FF";
newDiv.style.padding = "5px";
//生成层内内容
newDiv.innerHTML = '<h4 style="font-size:14; margin:15 0 0 15;">' + "商品成功放入购物车 [<a href='javascript:cancel_div()' class='f6' >" + '关闭' + "</a>]<br><br>"+ cartinfo + "</h4>";
newDiv.innerHTML += "<br /><center><a href='http://caihong19870228.blog.163.com/blog/flow.php'>进入购物车</a> <a [<a href='javascript:cancel_div()'>继续购物</a></center>";
document.body.appendChild(newDiv);
// mask图层
var newMask = document.createElement("div");
newMask.id = m;
newMask.style.position = "absolute";
newMask.style.zIndex = "9999";
newMask.style.width = document.body.scrollWidth + "px";
newMask.style.height = document.body.scrollHeight + "px";
newMask.style.top = "0px";
newMask.style.left = "0px";
newMask.style.background = "#FFF";
newMask.style.filter = "alpha(opacity=30)";
newMask.style.opacity = "0.40";
document.body.appendChild(newMask);
}
///////////////////////////////////////////
复制代码
二、再继续在 common.js 找到如下代码
复制代码
switch(result.confirm_type)
{
case '1' :
if (confirm(result.message)) location.href = cart_url;
break;
case '2' :
if (!confirm(result.message)) location.href = cart_url;
break;
case '3' :
location.href = cart_url;
break;
default :
break;
}
复制代码
修改成如下代码
复制代码
switch(result.confirm_type)
{
case '1' :
//if (confirm(result.message)) location.href = cart_url;
openDiv_chen(result.content)//将购物车信息作为参数传入
break;
case '2' :
//if (!confirm(result.message)) location.href = cart_url;
openDiv_chen(result.content)
break;
case '3' :
//location.href = cart_url;
openDiv_chen(result.content)
break;
default :
break;
}
复制代码
这样就可以了。
新闻资讯 更多
热门文章
- 178Moban源码谈谈免费源码与收费源码的区别
- 2帝国CMS忘记后台登陆用户名、密码、认证码的解决方法
- 3帝国CMS(EmpireCMS) v7.5后台任意代码执行漏洞及具体修复方法
- 4帝国CMS和WordPress 哪个好?哪个适合建站?
- 5如何解决Discuz的密码错误次数过多请15分钟后登陆的问题
- 6帝国cms灵动标签取得内容和栏目链接地址
- 7emlog pro 注册码“开心”教程(如果有一天,emlog官方版 或者 emlog免费版 跑路了,那用户怎么办?)
- 8织梦CMS在nginx下设置伪静态方法(附nginx伪静态规则)
- 9帝国cms后台登录出现”您还未登录”怎么解决?
- 10帝国cms7.5忘记登录密码 和忘记登录认证码以及多次登录 失败被锁定解决办法