Thursday, July 14, 2011

เมธอดต่างๆ ของ Javascript ที่ใช้ใน WebPage

เมธอด ของ Javascript
เมธอด ของ Javascript สำหรับ JavaScript นักพัฒนาเว็บไซต์มักจะใช้ Object ต่างๆที่มีอยู่ใน Javascript มาใช้ประกอบกับการทำเว็บไซต์ ซึ่ง JavaScript นั้นมีเมธอดต่างๆดังนี้
document.write(“text”) 
เมธอดนี้ จะใช้แสดงข้อความต่างๆในหน้าเว็บเพจ
docment.clear()
เมธอดนี้ใช้สำหรับ ลบหน้าเว็บเพจทั้งหมด

window.open()
เมธอดนี้ใช้สำหรับเปิด Browser ใหม่
history.go()
เมธอดนี้ใช้สำหรับ ระบุหน้าที่ต้องการ สามารถระบุจากประวัติการเปิดการเปิดหน้าเว็บเพจที่ผ่านมา

document.bgColor=”code color”

เมธอดนี้ใช้สำหรับกำหนดสีพื้นของเว็บเพจ
document.fgColor=”code color”
เมธอดนี้ใช้สำหรับกำหนดสีของตัวอักษรบนเว็บเพจ
document.title
เมธอดนี้ใช้สำหรับ แสดงชื่อของเว็บเพจ
document.lastModified
เมธอดนี้สำหรับ แสดงวันที่ มีการปรับแต่งหน้าเว็บเพจครั้งสุดท้าย

Wednesday, July 13, 2011

เป็นตัวอักษรวิ่งอยู่ในหน้าเว็บ ในช่องที่กำหนด

<html>
<title>www.thaiall.com</title>
<script language="JavaScript">
<!--
var timerID = null;
var timerRunning = false;
var id,pause=0,position=0;
function ticker() {
var i,k,msg="TEST";
k=(60/msg.length)+1;
for(i=0;i<=k;i++) msg+=" "+msg;
document.form2.ticker.value=msg.substring(position,position+100);
if(position++==300) position=0;
id=setTimeout("ticker()",2000/5);
}
//-->
</script>
<body onload="ticker()">
<form name="form2">
<input type="text" name="ticker" size="70" value="">
</form>
</body></html>

Tuesday, July 12, 2011

javaScript Array

<html>
<body>

<script type="text/javascript">
var i;
var mycars = new Array();
mycars[0] = "Saab";
mycars[1] = "Volvo";
mycars[2] = "BMW";

for (i=0;i<mycars.length;i++)
{
document.write(mycars[i] + "<br />");
}
</script>

</body>
</html>

HTML Image

<html>
<body>

<img src="angry.gif" alt="Angry face" width="32" height="32" />

</body>
</html>

HTML Links

Example

<a href="http://www.w3schools.com/" target="_blank">Visit W3Schools!</a>

HTML Styles

HTML Style Example - Background Color

The background-color property defines the background color for an element:

Example

<html>

<body style="background-color:yellow;">
<h2 style="background-color:red;">This is a heading</h2>
<p style="background-color:green;">This is a paragraph.</p>
</body>

</html>
The background-color property makes the "old" bgcolor attribute obsolete.


HTML Style Example - Font, Color and Size

The font-family, color, and font-size properties defines the font, color, and size of the text in an element:

Example

<html>

<body>
<h1 style="font-family:verdana;">A heading</h1>
<p style="font-family:arial;color:red;font-size:20px;">A paragraph.</p>
</body>

</html>

The font-family, color, and font-size properties make the old <font> tag obsolete.

HTML Style Example - Text Alignment

The text-align property specifies the horizontal alignment of text in an element:

Example

<html>

<body>
<h1 style="text-align:center;">Center-aligned heading</h1>
<p>This is a paragraph.</p>
</body>

</html

HTML Fonts

Example

<p>
<font size="5" face="arial" color="red">
This paragraph is in Arial, size 5, and in red text color.
</font>
</p>

<p>
<font size="3" face="verdana" color="blue">
This paragraph is in Arial, size 5, and in red text color.
</font>
</p>