Dr. Mark Humphrys

School of Computing. Dublin City University.

Home      Blog      Teaching      Research      Contact

Search:

CA249      CA318      CA425      CA651

w2mind.computing.dcu.ie      w2mind.org

Missing
DCU student

CASE3 student Paul Bunbury is missing since Thur 2 Feb 2012.
See appeals on crime.ie and garda.ie and facebook.

He is a great coder. See DCU page and boards.ie page.
He won major coding contests in 2010 and 2011.
He is author of the brilliant "FloodItWorld".
DCU can confirm that in Jan 2012 he passed all 6 modules comfortably.


JavaScript




Document Object Model (DOM)



Debugging

Debugging Javascript can be difficult. Where do you write output debug info to? Also no easy dump of variable like in PHP.


Javascript demos


Demo HTML (View Source) Javascript (View Source)
Javascript demo HTML (inline)
Javascript menu demo HTML

<a href="url"
 onmouseover="document.thebutton.src='on.png'" 
  onmouseout="document.thebutton.src='off.png'"
><img name="thebutton" src="off.png"></a>
(inline)

Javascript page change demo HTML

<input name=thefield  onBlur=recalculate()  > 

<p id="thetotal">0.00</p>
(inline)

function recalculate() 
{
 var x = document.theform.thefield.value;
...
 thetotal.innerHTML = total;
}
Javascript syntax highlighting HTML JS



Other things you can do with Javascript

  1. How to block (or redirect) a link to me from a certain site:
     
     
    var referrer = document.referrer;   
    var badstring = "BADSITE.COM";
      
    if ( referrer.indexOf(badstring) != -1 )
    {
     window.location = "http://mysite.com/badsite.redirect.html";
    }
    
    

  2. How to stop another site enclosing me in a frame.
    See examples.
     
    
    if (top != self)
     top.location.href = self.location.href;
     
    

  3. Hide mailto: link from spambots. See example.
    View Source
     
    
    s1 = "<a href=mail";
    s1 = s1 + "to:user";
    s1 = s1 + "id@comp";
    
    s2 = "uting.dcu.ie>email me</a>";
     
    document.write ( s1 + s2 );
    
    



Ajax


Browser-independent code

Javascript Ajax standards have varied across browsers. Can be tricky to write browser-independent, backward-compatible code.


Javascript Ajax demos


Demo HTML (View Source) Javascript (View Source)
Javascript Ajax demo HTML JS
Javascript Ajax demo - calling a script HTML

JS

Javascript Ajax - Parsing XML on the client side HTML JS



Feeds      HumphrysFamilyTree.com

Bookmark and Share           On Internet since 1987.