function popupTips() { var arg = arguments, txt = '', speed = 300, zIndex = 9200, time = 1500; if (arg.length == 1 && typeof(arg[0]) == 'string') { txt = arg[0]; } else if (arg.length == 2 && typeof(arg[0]) == 'string' && !isNaN(arg[1])) { txt = arg[0]; time = arg[1]; } if ($('div.tips_popup').length >= 1) { clearTimeout(timer); clearTimeout(removeTimer); $('#tipsPopup').text(txt); var timer = setTimeout(tipRemove, time); } else { var tipsStr = ''; alert(tipsStr); $(tipsStr).appendTo($('body')); var tpp = $('#tipsPopup'); console.log(tpp.height()) console.log(tpp.width()) tpp.css({ left: (parseInt($(window).width()) - parseInt(tpp.width()) - 20) / 2, top: (parseInt($(window).height()) - parseInt(tpp.height()) - 20) / 2, zIndex: zIndex }); tpp.css('visibility', 'inherit').show(speed); var timer = setTimeout(tipRemove, time); } ; function tipRemove() { var tsp = $('#tipsPopup'); tsp.hide(speed); var removeTimer = setTimeout(function () { tsp.remove() }, speed); } }