SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict sedna's Avatar
    Join Date
    Jan 2006
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    what up with my code

    Hey all,

    whats up with this code as what is ment to happen is the user clicks a link nd an alert box should open however it dont here is my coding

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    
    <head>
    	
    	<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
    	<meta name="author" content="Cobra Internet">
    <script type="text/javascript" src="test.js"></script>
    	<title>Untitled 1</title>
    </head>
    
    <body>
    
    <p>The first captain of the USS enterprise was 
    	<a id="wiki" href="http://www.test.com"> Chris Pike</a></p>
    
    </body>
    </html>
    and my javascript test.js file

    Code:
    var wiki = 
    {
    	clickhandler: function()
    	{
    		alert("Dont velive everything you read on wikiepedia");
    	}
    };

  2. #2
    SitePoint Zealot loathsome's Avatar
    Join Date
    Jul 2008
    Location
    Norway
    Posts
    121
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I strongly suggest you take a look at jQuery. Once installed, this code would work flawlessly.

    Code:
    $(document).ready(function (){
       $("div#wiki").click(function(){
         alert('Dont velive everything you read on wikiepedia');
       });
    });
    Time you enjoy wasting is not wasted time.

    Loathsome Systems

  3. #3
    SitePoint Addict sedna's Avatar
    Join Date
    Jan 2006
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you ever so much it worked, I do want to learn javascript however the book that I have called sitepoint simply javascript is not all what it's made up to be as it does not really go into detail about jquery.

  4. #4
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    It cant go into detail about every javascript framework available - it would be encyclopedia size! The book is meant as an introduction to Javascript principles and methodology, not the intricate workings of javascript frameworks.
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  5. #5
    SitePoint Zealot loathsome's Avatar
    Join Date
    Jul 2008
    Location
    Norway
    Posts
    121
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by sedna View Post
    Thank you ever so much it worked, I do want to learn javascript however the book that I have called sitepoint simply javascript is not all what it's made up to be as it does not really go into detail about jquery.
    If you want to learn JavaScript, I actually suggest you just go with jQuery. The documentation is excellent, and it makes JS-life so much easier. From the page:
    jQuery is designed to change the way that you write JavaScript.
    For me, jQuery has achieved their goal

    Best of luck.
    Time you enjoy wasting is not wasted time.

    Loathsome Systems


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •