- var BROWSER = {};
- var USERAGENT = navigator.userAgent.toLowerCase();
- browserVersion({'ie':'msie','firefox':'','chrome':'','opera':'','safari':'','mozilla':'','webkit':'','maxthon':'','qq':'qqbrowser'});
- if(BROWSER.safari) {
- BROWSER.firefox = true;
- }
- BROWSER.opera = BROWSER.opera ? opera.version() : 0;
- htmlNODE = document.getElementsByTagName('head')[0].parentNode;
- if(BROWSER.ie) {
- HTMLNODE.className = 'ie_all ie' + parseInt(BROWSER.ie);
- }
- function browserVersion(types) {
- var other = 1;
- for(i in types) {
- var v = types[i] ? types[i] : i;
- if(USERAGENT.indexOf(v) != -1) {
- var re = new RegExp(v + '(\\\\/|\\\\s)([\\\\d\\\\.]+)', 'ig');
- var matches = re.exec(USERAGENT);
- var ver = matches != null ? matches[2] : 0;
- other = ver !== 0 && v != 'mozilla' ? 0 : other;
- }else {
- var ver = 0;
- }
- eval('BROWSER.' + i + '= ver');
- }
- BROWSER.other = other;
- }
- var DozenFeedBack = {
- ox:0,
- oy:0,
- x:0,
- y:0,
- host:'',
- authkey:'',
- interval:30000,
- timer:null,
- divobj:null,
- windiv:null
- };
- function _open_window(url) {
- var empty_div = document.createElement('div');
- var div = document.createElement('div');
- var iframe = document.createElement('iframe');
- var body = document.getElementsByTagName('body')[0];
- if(DozenFeedBack.windiv != null){
- try {
- body.removeChild(DozenFeedBack.windiv);
- } catch(e){}
- DozenFeedBack.windiv = null;
- }
- iframe.setAttribute( "border", "0")
- iframe.setAttribute("frameborder", "0", 0);
- iframe.setAttribute( 'marginwidth', '0');
- iframe.setAttribute( 'marginheight', '0');
- iframe.setAttribute( 'style', 'overflow-x:hidden; overflow-y:auto');
- if(BROWSER.ie) {
- iframe.setAttribute( "width", "669px");
- iframe.setAttribute( "height", "350px");
- div.style.width = '670px';
- } else {
- div.style.width = '669px';
- iframe.setAttribute( "width", "669px");
- iframe.setAttribute( "height", "350px");
- }
- iframe.style.left ='0px';
- iframe.style.top = '50px';
- div.setAttribute('id','windiv');
- div.setAttribute('class','_windiv');
- div.style.position = 'absolute';
- div.style.left = (body.clientWidth - 670)/2 + "px";
- div.style.top = '100px';
- div.style.zIndex = '9999999';
- div.style.display ='inline';
- div.innerHTML = '<div style="margin:0 auto;width:669px;height:38px; text-align:center;background-image:url('+DozenFeedBack.host+'/template/default/style/dozen/feedback_01_1.gif)"></div><div id="_DozenCloseBtn" style="left:638px;top:8px;position:absolute;width:23px;height:21px; text-align:center;background-image:url('+DozenFeedBack.host+'/static/image/feedback/feedback_close.gif);z-index:99999;"></div>';
- iframe.src = url;
- empty_div.appendChild(div);
- div.appendChild(iframe);
- body.appendChild(div);
- var btn = document.getElementById("_DozenCloseBtn");
- btn.onclick = function(e){
- body.removeChild(div);
- };
- btn.onmouseover = function(e) {
- if(!BROWSER.ie) {
- div.style.cursor = 'pointer';
- } else {
- div.style.cursor = 'hand';
- }
- }
- DozenFeedBack.windiv = div;
- document.body.onclick = function(){
- //reSetIframe(iframe);
- }
- function reSetIframe(iframe){
- try{
- var bHeight = iframe.contentWindow.document.body.scrollHeight;
- var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
- var height = Math.max(bHeight, dHeight);
- iframe.height = height;
- }catch (ex){}
- }
- }
- //控制层拖动start
- var ie=document.all;
- var nn6=document.getElementById&&!document.all;
- var isdrag=false;
- var y,x;
- var oDragObj;
- function moveMouse(e) {
- if (isdrag) {
- oDragObj.style.top = (nn6 ? nTY + e.clientY - y : nTY + event.clientY - y)+"px";
- oDragObj.style.left = (nn6 ? nTX + e.clientX - x : nTX + event.clientX - x)+"px";
- return false;
- }
- }
- function initDrag(e) {
- var oDragHandle = nn6 ? e.target : event.srcElement;
- var topElement = "HTML";
- while (oDragHandle.tagName != topElement && oDragHandle.id != "windiv") {
- oDragHandle = nn6 ? oDragHandle.parentNode : oDragHandle.parentElement;
- }
- if (oDragHandle.id=="windiv" ) {
- isdrag = true;
- oDragObj = oDragHandle;
- nTY = parseInt(oDragObj.style.top+0);
- y = nn6 ? e.clientY : event.clientY;
- nTX = parseInt(oDragObj.style.left+0);
- x = nn6 ? e.clientX : event.clientX;
- document.onmousemove=moveMouse;
- return false;
- }
- }
- document.onmousedown=initDrag;
- document.onmouseup=new Function("isdrag=false");
- //控制层拖动结束
- //该片段来自于http://www.codesnippet.cn/detail/250420133021.html
来源: http://www.codesnippet.cn/detail/250420133021.html