80 likes | 254 Views
JavaScript. Client Side Processing. JavaScript. JavaScript runs in the browser (the client) JavaScript programs do not need to access the server. JavaScript programs can change the content and the appearance of a page. Using onload.
E N D
JavaScript Client Side Processing
JavaScript • JavaScript runs in the browser (the client) • JavaScript programs do not need to access the server. • JavaScript programs can change the content and the appearance of a page. Lecture 8: JavaScript
Using onload • The JavaScript onload is different to the C# Page_Load. It happens at the client: • Include this line in the <source> view of your page: <body onload="ol()"> • It will make the page run the JavaScript function ol Lecture 5: Review
backgroundColor • You can set the background-color most elements: function ol(){ document.body.style.backgroundColor="red"; } Lecture 5: Review
setInterval • You can use setInterval to make a function happen regularly. • Usually you call setInterval in onload function ol(){ setInterval(flipText,1000); } Lecture 5: Review
getElementById • If an HTML element has an ID set you can find it and change it from JavaScript: varlbl = document.getElementById("Label1"); lbl.innerHTML= "Andrew was here"; Lecture 5: Review
ToolTip and title • The ToolTip property in Visual Studio can be used to “hide” information that you show later. • You can swap innerHTML and title: varlbl = document.getElementById("Label1"); vartmp = lbl.innerHTML; lbl.innerHTML= lbl.title; lbl.title= tmp; Lecture 5: Review
Summary • JavaScript is different to C# • Many things are similar. • JavaScript runs at the client, C# runs at the server. • It can be difficult to debug JavaScript Lecture 5: Review