หน้า 1 จากทั้งหมด 1

มา รวม javascript จาวาสคริบ สำหรับ web programmer

โพสต์แล้ว: 16/05/2006 12:17 pm
โดย 4404
ใครมีเอามา แนะนำกันบ้างนะครับ
ผม เอา ก่อน เลย
ไว้ ยืนยันกสรลบ แล้ว ให้ลิงค์ ไปยังไฟล์ ที่ทำหน้าที่ลบ
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function confirmDelete(TEXT,URL) {
if (window.confirm('Delete '+TEXT+' ?')) { window.open(URL,"_top"); }
}
// End -->
</script>

โพสต์แล้ว: 16/05/2006 6:56 pm
โดย 4404
ลองอ่านดูนะครับ อาจมีประโยชน์
New in JavaScript 1.6
Contents
[hide]
1 E4X
2 Array extras
3 Array and String generics



[edit]E4X
ECMAScript for XML (E4X) is a powerful technology for creating and processing XML content within JavaScript. We're going to continue to improve our E4X support, including adding transparent integration with the existing DOM, but developers who are building XML-based web applications can benefit from E4X support in Firefox 1.5.

You can still use the standard MIME type when using E4X:

<script type="text/javascript">
However, E4X syntax may conflict with the common practice of putting scripts into HTML comments (<!--...-->) to hide them from old browsers. E4X may also conflict with the more modern practice of putting scripts within XML CDATA sections (<![CDATA[...]]>) to allow the symbols "<" and ">" in the script (note that this does not apply to HTML). If you see inexplicable syntax errors, add "; e4x=1" to the MIME type:

<script type="text/javascript; e4x=1">
Note that scripts in extensions always treat HTML comments as E4X literals. That is, the "e4x=1" is implicit.

[edit]Array extras
There are seven new Array methods that can be separated into two categories, item location methods and iterative methods. The item location methods are:

indexOf() - returns the index of the given item's first occurrence.
lastIndexOf() - returns the index of the given item's last occurrence.
The iterative methods are:

every() - runs a function on every item in the array and returns true if the function returns true for every item.
filter() - runs a function on every item in the array and returns an array of all items for which the function returns true.
forEach() - runs a function on every item in the array.
map() - runs a function on every item in the array and returns the results in an array.
some() - runs a function on every item in the array and returns true if the function returns true for any item.
For more information, see Nicholas C. Zakas' article, Mozilla's New Array Methods.

[edit]Array and String generics
Sometimes you would like to apply array methods to strings. By doing this, you treat a string as an array of characters. For example, in order to check that every character in the variable str is a letter, you would write:

function isLetter(character) {
return (character >= "a" && character <= "z");
}

if (Array.prototype.every.call(str, isLetter))
alert("The string '" + str + "' contains only letters!");
This notation is rather wasteful and JavaScript 1.6 introduces a generic shorthand:

if (Array.every(str, isLetter))
alert("The string '" + str + "' contains only letters!");
Similarly you can easily apply String methods to any object:

var num = 15;
alert(String.replace(num, /5/, '2'));
Retrieved from "http://developer.mozilla.org/en/docs/Ne ... Script_1.6"

โพสต์แล้ว: 23/05/2006 12:53 pm
โดย icphysics
การ redirect โดยใช้ javascript
<script>setTimeout("top.document.location='index.php",2000);
2000 = 2 วิ
index.php คือไฟล์ที่เราต้องการ ไป

โพสต์แล้ว: 24/05/2006 1:46 pm
โดย 4404
อีกแบบ เอาแปะ ไว้ที่ head นะครับ
<script>
if (parent.frames.length==0)
//CHANGE "index.htm" to the URL of your main frame page
window.location.replace("index.htm")
</script>
อันนี้ ใช้ กับ frames ได้ด้วย คือ คือ จะเปลียน freams ให้เลย