Myanmar IT Resource Forum
Myanmar IT Resource Forum
Myanmar IT Resource Forum

You are not connected. Please login or register

View previous topic View next topic Go down  Message [Page 1 of 1]

130 Javascript Empty 30 Javascript 25th February 2010, 10:23 am

z3r0c00l

z3r0c00l
Administrator



Administrator
က်ြန္ေတာ္ 30 Javascript ဆိုတဲ့စာအုပ္ေလးတစ္အုပ္ရထားပါတယ္။ alt.332 ေရးတဲ့ Javascript ဆိုပါလား ဆိုတဲ့ ပို႔စ္ နဲ႕ က်ြန္ေတာ္ေရးထားတာေလးကို ေပါင္းၿပီးဖတ္လိုက္ရင္ေတာ့ အဆင္ေျပပါလိမ့္မယ္။ က်ြန္ေတာ္မအားတာေၾကာင့္ PHP လိုမ်ိဳး ျမန္မာျပန္ၿပီးေတာ့ မတင္ေပးႏိုင္တာကိုေတာ့ ခြင့္လႊတ္ပါခင္ဗ်ာ။Simple English ျဖစ္တဲ့အတြက္ အားလံုးနားလည္လြယ္လိမ့္မယ္လို႔လဲ ထင္ပါတယ္။ က်ြန္ေတာ္အားတာနဲ႕ ဒီပို႔စ္ေတြအကုန္လံုးကို ျမန္မာလိုျပန္ၿပီး edit ျပန္လုပ္ေပးမယ္ဆိုတဲ့အေၾကာင္း ကတိျပဳပါတယ္ခင္ဗ်ာ။ ကဲ......စလိုက္ၾကရေအာင္။
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Agenda
Generating HTML Dynamically
• Monitoring User Events
• Basic JavaScript Syntax
• Applications
– Using JavaScript to customize Web pages
– Using JavaScript to make pages more dynamic
– Using JavaScript to validate CGI forms
– Using JavaScript to manipulate HTTP cookies
– Using JavaScript to interact with and control frames
– Controlling applets and calling Java from JavaScript
– Accessing JavaScript from Java

Generating HTML Dynamically
Idea
– Script is interpreted as page is loaded, and uses
document.write or document.writeln to insert
HTML at the location the script occurs

• Template
Code:

<BODY>
Regular HTML
<SCRIPT TYPE="text/javascript">
<!--
Build HTML Here
// -->
</SCRIPT>
More Regular HTML
</BODY>

230 Javascript Empty Re: 30 Javascript 25th February 2010, 10:53 am

z3r0c00l

z3r0c00l
Administrator



Administrator
A Simple Script
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<HTML>
<HEAD>
<TITLE>First JavaScript Page</TITLE>
</HEAD>
<BODY>
<H1>First JavaScript Page</H1>
<SCRIPT TYPE="text/javascript">
<!--
document.write("<HR>");
document.write("Hello World Wide Web");
document.write("<HR>");
// -->
</SCRIPT>
</BODY>
</HTML>

ဒီCode ကိုေရးၿပီး Run ၾကည့္တဲ့အခါ ဒီလိုျမင္ရပါလိမ့္မယ္။
[You must be registered and logged in to see this image.]

330 Javascript Empty Re: 30 Javascript 25th February 2010, 11:18 am

z3r0c00l

z3r0c00l
Administrator



Administrator
Extracting Document Info with JavaScript, Example
Code:
<HTML>
<HEAD>
<TITLE>Extracting Document Info with JavaScript</TITLE>
</HEAD>
<BODY BGCOLOR="WHITE">
<H1>Extracting Document Info with JavaScript</H1>
<HR>
<SCRIPT TYPE="text/javascript">
<!--
function referringPage() {
if (document.referrer.length == 0) {
return("<I>none</I>");
} else {
return(document.referrer);
}
}...
document.writeln
("Document Info:\n" +
"<UL>\n" +
"  <LI><B>URL:</B> " + document.location + "\n" +
"  <LI><B>Modification Date:</B> " + "\n" +
document.lastModified + "\n" +
"  <LI><B>Title:</B> " + document.title + "\n" +
"  <LI><B>Referring page:</B> " + referringPage() + "\n" +
"</UL>");
document.writeln
("Browser Info:" + "\n" +
"<UL>" + "\n" +
"  <LI><B>Name:</B> " + navigator.appName + "\n" +
"  <LI><B>Version:</B> " + navigator.appVersion + "\n" +
"</UL>");
// -->
</SCRIPT>
<HR>
</BODY>
</HTML>

ဒါေလးကေတာ့ Document Info နဲ႕ Browser Info ကိုၾကည့္တာပါ။ ဒါကို Run လုိက္ရင္ ဒီလိုျမင္ရပါလိမ့္မယ္။
[You must be registered and logged in to see this image.]

430 Javascript Empty Re: 30 Javascript 25th February 2010, 11:32 am

z3r0c00l

z3r0c00l
Administrator



Administrator
Multi-Browser Compatibility
1. Use Language Attribute
Code:
<SCRIPT LANGUAGE="JavaScript">
<!--
languageVersion = "1.0";
// -->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.1">
<!--
languageVersion = "1.1";
// -->
</SCRIPT>
...
<SCRIPT LANGUAGE="JavaScript1.5">
<!--
languageVersion = "1.5";
// -->
</SCRIPT>

Multi-Browser Compatibility,cont.
2. Use Vendor/Version Info
– navigator.appName
– navigator.appVersion

Monitoring User Events
Use Various onXxx Attributes
– onClick
– onLoad
– onMouseOver
– onFocus
– etc.

530 Javascript Empty Re: 30 Javascript 25th February 2010, 11:44 am

z3r0c00l

z3r0c00l
Administrator



Administrator
User Events, Example
Code:
<HTML>
<HEAD>
<TITLE>Simple JavaScript Button</TITLE>
<SCRIPT TYPE="text/javascript">
<!--
function dontClick() {
alert("I told you not to click!");
}
// -->
</SCRIPT>
</HEAD>
<BODY BGCOLOR="WHITE">
<H1>Simple JavaScript Button</H1>
<FORM>
<INPUT TYPE="BUTTON"
VALUE="Don't Click Me"
onClick="dontClick()">
</FORM>
</BODY>
</HTML>

Result
[You must be registered and logged in to see this image.]

630 Javascript Empty Re: 30 Javascript 25th February 2010, 12:05 pm

z3r0c00l

z3r0c00l
Administrator



Administrator
JavaScript Syntax: Dynamic Typing
• Idea
– Like Lisp, values are typed, not variables
– A value is only checked for proper type when it is
operated upon
• Example
var x = 5; // int
x = 5.5; // float
x = "five point five"; // String

JavaScript Syntax: Function Declarations
1. Declaration Syntax
– Functions are declared using the function reserved word
– The return value is not declared, nor are the types of the
arguments
– Examples:
Code:
function square(x) {
return(x * x);
}
function factorial(n) {
if (n <= 0) {
return(1);
} else {
return(n * factorial(n - 1));
}
}

730 Javascript Empty Re: 30 Javascript 25th February 2010, 7:01 pm

#twotwo22#

#twotwo22#
MITR Beginner



MITR Beginner
မိုက္တယ္ဗ်..
ေတာ္ေတာ္အသံုး၀င္တယ္
က်ြန္ေတာ္အားတာနဲ႕ ဒီပို႔စ္ေတြအကုန္လံုးကို ျမန္မာလိုျပန္ၿပီး edit ျပန္လုပ္ေပးမယ္ဆိုတဲ့အေၾကာင္း ကတိျပဳပါတယ္ခင္ဗ်ာ
ျမန္မာလိုျပန္ျပီးရင္..အသိေလးေပးဦးေနာ္...
ေက်းဇူးတင္ပါတယ္
.....................................
signature က အားရစရာၾကီး Razz

830 Javascript Empty Re: 30 Javascript 3rd March 2010, 7:13 pm

Opera

Opera
MITR Reader



MITR Reader
sig ၾကီး အဲေလာက္ၾကီးေနတာ Member ေတြကို မ်က္စိေနာက္ေစပါဦးမယ္။

Anyway, Thanks for your sharing.

Sponsored content


View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum

 

Create a forum | Computers and Internet | Computers | ©phpBB | Free forum support | Report an abuse | Cookies | Forumotion.com