Friday, October 17, 2014

FireFox page-break-before After DIV Problem

FireFox เมื่อใช้ page-break-before ใต้ <div> ในหน้าพิมพ์หน้าที่ 2 มักเกิดปัญหาตัวหนังสือขึ้นมากองอยู่บนบรรทัดแรกหมด วิธีแก้ไขปัญหานี้จากยูสเซอร์ RivendellH

อ้างอิงจาก
http://forums.mozillazine.org/viewtopic.php?f=25&t=278578

Example: 
<div> 
... 
</div> 
<br style="page-break-before: always;" clear="all" /> 
does not create a page break in a print preview or the actual printing. 

This works: 
<p> 
... 
</p> 
<br style="page-break-before: always;" clear="all" /> 

This works: 
<div> 
... 
</div> 
<p><br style="page-break-before: always;" clear="all" /></p> 

And this works: 
<div> 
... 
</div> 
<br style="page-break-after: always;" clear="all" />

Tuesday, August 5, 2014

ปัญหา document.getElementById('myInput').focus(); ไม่ทำงานบน IE

ปัญหานี้มักเจอเวลาที่สั่งให้ focus ทันทีที่โหลดหน้าขึ้นมา ซึ่งถ้าเป็น browser อื่นๆที่ไม่ใช่ IE จะไม่มีปัญหาอะไร แต่ถ้าต้องการให้ทำงานได้บน IE ด้วยจำเป็นต้องใส่ delay เข้าไปด้วยเพราะบางทีถ้าหน้าไหนที่โหลดหน้าช้า IE จะไม่ทำคำสั่งย้อนหลังให้
ตัวอย่างการใช้งาน

<html>
 
<head>
<title>focus is working in IE</title>
</head>
<body>
 
<form >
    <input id="myInput" type="text" value='testing'><br>
</form>
</body>
 
 <script type="text/javascript">
 setTimeout(function() { document.getElementById('myInput').focus(); }, 1000);
</script>
 
</html>
อ้างอิงจาก http://www.mkyong.com/javascript/focus-is-not-working-in-ie-solution/

Friday, February 21, 2014

การทำเว็บไซต์ไม่ให้ Chrome ถามเวลาที่ดาวน์โหลดไฟล์ zip ที่มีไฟล์ .exe อยู่ข้างใน

สามารถทำได้โดยการเพิ่ม Tag Content Type Zip เข้าไปที่ส่วน Header ของไฟล์เช่น
<head>
<meta http-equiv="Content-Type" content="HTML,CSS,XML,JavaScript">
<meta http-equiv="Content-Type" content="application/zip .zip">
<meta charset="UTF-8">
</head>

อ้างอิงจาก
http://www.sitepoint.com/forums/showthread.php?940794-File-(-zip)-is-not-commonly-downloaded-and-could-be-dangerousded-and-could-be-dangerous

Saturday, January 25, 2014

การทำปุ่ม Home, End บน Mac. OS ให้เหมือน Windows OS

ปัญหาหนึ่งที่พบเจอบ่อยๆ คือความคุ้นเคยในการใช้ text editor บน windows แล้วพอสลับไปใช้เครื่อง mac. คือการหลงไปกดปุ่ม Home หรือ End แทนที่จะไปที่หัวหรือท้ายบรรทัด แต่กลับกระโดดไปที่ส่วนบนสุดหรือล่างสุดของไฟล์ทำให้เสียเวลามาก วิธีแก้คือเข้าไปเพิ่มไฟล์ DefaultKeyBinding.dict เข้าไปในระบบ

To get your Home and End keys working properly on Mac OS X (in my case, Mountain Lion, although this should work in prior versions back to at least Tiger), simply open the Terminal and do this:

$ cd ~/Library
$ mkdir KeyBindings
$ cd KeyBindings
$ nano DefaultKeyBinding.dict

Put these lines in that file, including the curly braces:

{
/* Remap Home / End keys to be correct */
"\UF729" = "moveToBeginningOfLine:"; /* Home */
"\UF72B" = "moveToEndOfLine:"; /* End */
"$\UF729" = "moveToBeginningOfLineAndModifySelection:"; /* Shift + Home */
"$\UF72B" = "moveToEndOfLineAndModifySelection:"; /* Shift + End */
"^\UF729" = "moveToBeginningOfDocument:"; /* Ctrl + Home */
"^\UF72B" = "moveToEndOfDocument:"; /* Ctrl + End */
"$^\UF729" = "moveToBeginningOfDocumentAndModifySelection:"; /* Shift + Ctrl + Home */
"$^\UF72B" = "moveToEndOfDocumentAndModifySelection:"; /* Shift + Ctrl + End */
}

Press Ctrl+O and then Enter to save the file, and Ctrl+X to exit. Restart your computer to have it take full effect.

แต่ในบางโปรแกรมที่มีความฉลาดในการกำหนดคีย์เองอยู่แล้วก็สามารถเข้าไปกำหนดได้เลย เช่น Eclipse โดยเข้าไปที่ Preferences -> General.Keys -> Text Editing

source:
http://mwholt.blogspot.com/2012/09/fix-home-and-end-keys-on-mac-os-x.html
http://www.kelek.com/blog/2006/09/16/fixing_home_end.html