SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot mr_jeep's Avatar
    Join Date
    Feb 2004
    Location
    Canada
    Posts
    131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Override onmouseover in a Class, now I can't get my class attributes.

    Hi,
    I'm currently working with Javascript to build some "dynamic" tabs. Basicly, the tab "onmouseover" and "onmouseout" event have been overriden to change the tab's css class.

    Here's the class :

    Code:
    function HtmlTab(id)
    {
    
        this.id = id;
    
        this.tab = document.getElementById(id);
        
        this.cssover = "over";
        this.cssout  = "out";
    
    
    	this.tab.onmouseover = function()
    	{
    
    		this.className = this.cssover; // NOT WORKING
    
    	}
    
    
    	this.tab.onmouseout = function()
    	{
    
    		this.className = "gen";
    
    	}
    
    }
    My problem is, I cannot access my HtmlTab class attributes from the this.tab.onmouseover function. Anyone knows a way to fix this ?

    Thank you very much !
    I'd appreciate if you would tell me if something I wrote is spelled wrong

  2. #2
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,750
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How exactly are you accessing this class?

  3. #3
    SitePoint Zealot mr_jeep's Avatar
    Join Date
    Feb 2004
    Location
    Canada
    Posts
    131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This way :

    Code:
    <div id="gnav">
    
    				<ul>
    
    					<li id="tab1" class="gen"><a href="index.php">Accueil</a></li>
    					<li id="tab2" class="gen"><a href="index.php?module=News_Index">Actualités</a></li>
    					<li id="tab3" class="gen"><a href="index.php?module=League_Index">Ligues</a></li>
    					<li id="tab4" class="gen"><a href="index.php?module=User_Index">Joueurs</a></li>
    					<li id="tab5" class="gen"><a href="#">Communauté</a></li>
    
    					<!-- -------------------- -->
    					<!-- Navigation : Gestion -->
    					<!-- -------------------- -->
    
    					<?php if ($user->isAdmin()) { ?>
    
    					<li id="tab6" class="gen"><a href="#">Gestion</a></li>
    
    					<?php } ?>
    
    				</ul>
    
    				<div class="fl-clear"></div>
    
    				<script language="Javascript">
    
    				var gNavTab1 = new HtmlTab("tab1", "");
    				var gNavTab2 = new HtmlTab("tab2", "News");
    				var gNavTab3 = new HtmlTab("tab3", "League");
    				var gNavTab4 = new HtmlTab("tab4", "User");
    				var gNavTab5 = new HtmlTab("tab5", "Community");
    
    				</script>
    
    			</div>
    I'd appreciate if you would tell me if something I wrote is spelled wrong

  4. #4
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,750
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You're passing HtmlTab 2 arguments, but it's only meant to accept 1.

  5. #5
    SitePoint Zealot mr_jeep's Avatar
    Join Date
    Feb 2004
    Location
    Canada
    Posts
    131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, this is not the point. I'm just wondering why, when I override the onmouseover method, I can't access my HtmlTab class properties.
    I'd appreciate if you would tell me if something I wrote is spelled wrong


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
  •