87,997
社区成员




<button type="button" id="btnShare">手机分享</button>
<script type="text/javascript">
function share_on_click(){
var btn = document.getElementById("btnShare");
var url = window.location.href;
var reg = /product_id=(\d+)/i;
var id = 888;
if(reg.test(url)){
id = RegExp.$1;
}
btn.onclick = function(){
var src = "http://qr.liantu.com/api.php?text=http://abc.com/wapdetail?product_id=" + id;
var div = document.createElement("div");
div.style.cssText = "position:absolute; width:300px; height:300px; left:50%; top:50%; margin:-150px 0 0 -150px;z-index:999";
div.innerHTML = "<img src='" + src + "' title='点击关闭'/>";
document.body.appendChild(div);
btn.style.display = "none";
div.onclick = function(){
btn.style.display = "block";
document.body.removeChild(div);
};
};
}
if(document.addEventListener){
window.addEventListener('load', share_on_click, false);
}else{
window.attachEvent('onload', share_on_click);
}
</script>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>_</title>
</head>
<body>
<button type="button" id="btnShare">手机分享</button>
</body>
<script type="text/javascript">
window.onload = function(){
var btn = document.getElementById("btnShare");
btn.onclick = function(){
var src = "http://qr.liantu.com/api.php?text=http://abc.com/wapdetail?product_id=888";
var div = document.createElement("div");
div.style.cssText = "position:absolute; width:300px; height:300px; left:50%; top:50%; margin:-150px 0 0 -150px;";
div.innerHTML = "<img src='" + src + "' title='点击关闭'/>";
document.body.appendChild(div);
div.onclick = function(){
document.body.removeChild(div);
};
};
};
</script>
</html>