SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2004
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Intrusive javascript code

    Hi all,

    I have fellow javascript code:
    Code:
    <ul id="menu">
    <li id="id1"><a href="#" onmouseover="javascript:changeClass('id', 'menuActived');" onmouseout="javascript:changeClass('oc_hotels', 'deactive');" >College Park Hotels</a>
    <ul>			
    	<li>
    	<a href="url" onmouseover="javascript:activeClass('id1');" onmouseout="javascript:handleClass('id1');" >
    	MENU 1 
    	</a>
    	<li>
    	<a href="url" onmouseover="javascript:activeClass('id1');" onmouseout="javascript:handleClass('id1');" >
    	MENU 2
    	</a>
    	<li>
    	<a href="url" onmouseover="javascript:activeClass('id1');" onmouseout="javascript:handleClass('id1');" >
    	MENU 3
    	</a>
    	</li>
    </ul>
    </ul>
    I would like transform this code in code less intrusive,such as remove onmouseout and onmousever from my html.

    but how I could make it ?

    the main problem is :

    Code:
    <li>
    <a href="url" onmouseover="javascript:activeClass('id1');" onmouseout="javascript:handleClass('id1');" >
    	MENU 
    	</a>

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    A good question.

    What you're referring to is good practice, the removal of inline javascript from your HTML. Most people call doing this "unobtrusive javascript" or "behavioural separation". This article is a good starting point and should help you translate what you have into clean, unobtrusive javascript in a separate file.


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
  •