SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Non-Member
    Join Date
    Sep 2005
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    simply javascript Core library

    Been following simply javascript & its use of the Core library.

    In the document access chapter, things make sense using Core library but having some probs trying to do the same execrcise in Prototype & Jquery. Below are the failed attempts at getting 2 exercises to work in prototype. Some help would be great. Thanks!

    1.
    Using core.js(This works)
    var StyleObject =
    {
    init: function()
    {
    var body = document.getElementsByTagName("body")[0];
    body.style.backgroundColor = "#000000";
    body.style.color = "#FFFFFF";
    }
    };
    Core.start(StyleObject);

    1a.
    Using prototype.js(This does not work)
    //declaring the class
    var StyleObject = Class.create();

    //defining the rest of the class implementation
    StyleObject.prototype = {

    initialize: function() {
    var body = document.getElementsByTagName("body")[0];
    body.style.backgroundColor = "#000000";
    body.style.color = "#FFFFFF";
    }
    };
    new StyleObject();

    2.
    Using core.js(This works)
    var changedClass =
    {
    init: function()
    {
    body = document.getElementsByTagName("body")[0];
    Core.addClass(body, "unreadable");
    }
    };

    Core.start(changedClass);

    2a.
    //declaring the class
    Using prototype.js(This does not work)
    var changedClass = Class.create();

    //defining the rest of the class implementation
    changedClass.prototype = {
    initialize: function()
    {
    var body = document.getElementsByTagName("body")[0];
    Element.addClassName(body, "unreadable");
    }
    };
    new changedClass();

  2. #2
    Non-Member
    Join Date
    Sep 2005
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    No Answer

    Hi

    wont anyone at least give some kind of answer?



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
  •