Category: Coding

BGE – HTML Links

The anchor tag <a></a> in html 5 is used to create a hyperlink between two documents. The <a></a> surrounds text or an image that then is used to activate the link stored in the href attribute.

Page1.html
1
2
3
4
5
6
7
8
9
10
11
12
<!doctype html>
<html>
<head>
<title> Page 1 </title>
</head>
<body>
<h1>Page 1</h1>
<p>
This is a <a href="page2.html">link</a> to page 2
</p>
</body>
</html>

In the example above the word link is linked to page2.html.

HTML/CSS Navigation Menu

I wasn’t overly happy with the way that this was shown on W3Schools. The navigation bar and dropdowns were on different pages and it wasn’t till you got to the end that you saw how it worked. Even then the sub page links were not held in a sub list they were displayed in a div.

I found this article, which gives a good explination (along with samples) of how you could create a multilevel naviational bar that uses lists. The code is quite complicated and it relies on element element selector.

 

Higher – Javascript mouse events

The code bellow uses mouse events to run a javascript function.

On line 15  the onmouseover and onmouseout events are used to call the function on line 6.

Line 7 targets the swap id and uses the argument passed to replace the image source.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<!doctype html>
<html>
<head>
 
<script type="text/javascript">
function changeImage(img_src) {
document.getElementById("swap").src = img_src;
 
}
</script>
 
</head>
<body>
<h1>roll over</h1>
<img id="swap" src="redButton.jpg" onmouseover='changeImage("blueButton.jpg")' onmouseout='changeImage("redButton.jpg")'>
 
</body>
</html>

N5 – Coding

Description and identification of coding to create and modify information systems including JavaScript mouse events.

Javascript is used in HTML documents to add interactivity. The HTML file below has a number of interactive elements to it. Use notepad++ to investigate it further.

Description, exemplification and implementation of coding to create and modify information system including the use of HTML with the tags for:
o Document
o Links
o Graphics

The documents below show a HTML document with the basic html document tags and a document showing the html tags for links and images

Higher – Coding (Revision)

Scripting

Including sections of program code in your website, to help make it more dynamic or interactive, is called scripting.

Client-side scripting

  •  A section of code is sent to the client computer and executed there, in the browser.
  • It is commonly used to add interactive elements to a webpage.
  • JavaScript is a language commonly used for client-side scripting.

Server-side scripting

  • A section of code is executed by the web server.
  • It is commonly used to create dynamic webpages, often connected to a database on the server.
  • Popular languages for server-side scripting include PHP, ASP, Perl and ColdFusion.

SEO (Search Engine Optimisation)

SEO is the process of improving the ranking of your webpage in search engine results, in order to increase traffic.

Some SEO techniques include:

  • Making sure each page of your site has a unique, concise and descriptive title contained in the <title> tag.
  • Using the description <meta> tag to include a summary of each page.
  • Using concise URLs.
  • Submit an XML sitemap to the companies which run the search engines
  • Using brief, descriptive filenames and alt text for images

Search engines and web crawlers

  • A web crawler (aka spider) is a piece of software which follows links from web page to web page, analyses the text on each page, and indexes the pages with related keywords.
  • Search engines then use this index to find relevant pages when you carry out a search.

Optimisation of code

Load times of webpages affect traffic. By making code more efficient, file sizes, and therefore load times, can be reduced.

Some techniques include:

  • Using a single CSS file to hold all the formatting information for the site.
  • Putting all JavaScript into a single external file, to reduce fetches from the server.
  • Remove/reduce internal commentary and white space.

Thank you to C O’Toole & A Madill from Braidhurst High School for allowing me to edit and publish this here.

Incrementing Counter

This is a programming statement which increases by a known amount, each time it is called.

  • Score=Score+1
  • One=One+1
  • Bonus=Bonus+10

Incrementing counters are often used inside loops to keep track of the number of iterations.

counter

In the example above the tries=tries+1 line is keeping track of how many times the loop has been iterated.

Python Selection – if:

diceToday we investigated the use of the if statement, this is a selection statement which allows Python to make choices.

We have updated our dice roll program from last time to include a for loop and multiple if statements. The program now displays a summary of the results of 1000 dice rolls.

For homework the class were asked to TRACS the program and we will discuss how efficient it is next time.