โดย mindphp » 16/09/2011 3:13 pm
กำหนดพื้นหลังตามขนาดหน้าจอ
โค้ด: เลือกทั้งหมด
if (document.viewport.getDimensions() .getHeight() == 800) {
$( 'body' ).setAttribute( 'background', '/img/bg-800x600.gif' );
} else if (document.viewport.getDimensions() .getHeight() == 1280) {
if (document.viewport.getDimensions() .getWidth() == 768) {
$( 'body' ).setAttribute( 'background', '/img/bg-1280x768.gif' );
} else if (document.viewport.getDimensions() .getWidth() == 1024) {
$( 'body' ).setAttribute( 'background', '/img/bg-1280x1024.gif' );
} else {
$( 'body' ).setAttribute( 'background', '/img/bg-1280x1200.gif' );
}
กำหนดพื้นหลังตามขนาดหน้าจอ
[code]if (document.viewport.getDimensions() .getHeight() == 800) {
$( 'body' ).setAttribute( 'background', '/img/bg-800x600.gif' );
} else if (document.viewport.getDimensions() .getHeight() == 1280) {
if (document.viewport.getDimensions() .getWidth() == 768) {
$( 'body' ).setAttribute( 'background', '/img/bg-1280x768.gif' );
} else if (document.viewport.getDimensions() .getWidth() == 1024) {
$( 'body' ).setAttribute( 'background', '/img/bg-1280x1024.gif' );
} else {
$( 'body' ).setAttribute( 'background', '/img/bg-1280x1200.gif' );
}
[/code]