คำสั่งสร้าง popup อยู่ตรงกลางใช้กับ fire fox ไมไ่ด้ครับ

ถาม-ตอบ แนะนำไอเดียว โค้ดตัวอย่าง แนวทาง วิธีแก้ปัญหา คำสั่งสร้าง popup อยู่ตรงกลางใช้กับ fire fox ไมไ่ด้ครับ

คำสั่งสร้าง popup อยู่ตรงกลางใช้กับ fire fox ไมไ่ด้ครับ

ตามหัวข้อเลยนะครับ

function popup(url,name,windowWidth,windowHeight){    
myleft=(screen.width)?(screen.width-windowWidth)/2:100;	
mytop=(screen.height)?(screen.height-windowHeight)/2:100;	
properties = "width="+windowWidth+",height="+windowHeight;
properties +=",scrollbars=yes, top="+mytop+",left="+myleft;   
window.open(url,name,properties);

ใช้กับ fire fox ไมไ่ด้ครับผม 

 



Cpuhost 183.89.222.xxx 15-11-2010 15:12:27

คำแนะนำ และการใช้งาน

สมาชิก กรุณา ล็อกอินเข้าระบบ เพื่อตั้งคำถามใหม่ หรือ ตอบคำถาม สมาชิกใหม่ สมัครสมาชิกได้ที่ สมัครสมาชิก


  • ถาม-ตอบ กรุณา ล็อกอินเข้าระบบ
  • เปลี่ยน


    ( หรือ เข้าใช้งานผ่าน Social Login )

 ความคิดเห็นที่ 1
<script type='text/javascript' src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
jQuery.fn.center = function(init) {		
	var dxcenter = this;		
	if(!init) {
		dxcenter.css('margin-top', $(window).height() / 2 - this.height() / 2);
		dxcenter.css('margin-left', $(window).width() / 2 - this.width() / 2);
			//ถ้ามีการ resize ให้ทำการคำนวนใหม่
		$(window).resize(function() {
			dxcenter.center(!init);
		});		
	} else {			
		var marginTop = $(window).height() / 2 - this.height() / 2;
		var marginLeft = $(window).width() / 2 - this.width() / 2;
		
		marginTop = (marginTop < 0) ? 0 : marginTop;
		marginLeft = (marginLeft < 0) ? 0 : marginLeft;
		dxcenter.stop();
		dxcenter.animate({
				marginTop: marginTop, 
				marginLeft: marginLeft
			}, 250, 'swing' );
	}
}

$(document).ready(function() {
        $('#wrapper').center();
});
</script>

<style>
    #wrapper {
		border: 1px solid black;
		background-color: #E0E0EF;
		color:#FFFFFF;
		padding:15px;
        height:50px;
        width:650px;
		text-align:center;
    }
</style>

<div id="wrapper">
    <div id="my-content">
        <h1>อิหยังกะได้..แหม่นบ่อ ...!!</h1>
    </div>
</div>


ลองก้อบโค้ดไปวางไว้ในไฟล์ html แล้วลองรันดูครับ เผื่อได้ไอเดียอื่น



พระเจ้าที่ไม่เหงา 61.7.176.xxx 26-11-2010 12:32






เว็บไซต์ของเราให้บริการเนื้อหาบทความสำหรับนักพัฒนา โดยพึ่งพารายได้เล็กน้อยจากการแสดงโฆษณา โปรดสนับสนุนเว็บไซต์ของเราด้วยการปิดการใช้งานตัวปิดกั้นโฆษณา (Disable Ads Blocker) ขอบคุณครับ