Jump to content

Beginner onmouse java question with code


robbie71321

Recommended Posts

Just a technicality, but it can cause confusion.

 

This is JavaScript (JS) - it is a scripting language from Netscape.

 

Java is a Programming language from Sun Microsystems.

 

They are two different critters.

Link to comment
Share on other sites

document.write() is deprecated and is poor form. It works by immediately inserting text into the document while it is still being rendered by the browser - in this case, you're calling it after the document is loaded, so it ha nowhere to write to.

 

Try this:

 

function mouseOver()
{
alert("hello!!");
}
function mouseOut()
{
alert("goodbye!!!");
}

 

That should give you a popup when you go in and out of the area.

Link to comment
Share on other sites

What browser are you using to test in? If you're using IE, I would strongly suggest that you download Firefox, and use Firebug for Javascript debugging. Its error messages are much, much better than IE's.

 

This would not have shown up though. A debugger can only tell you when you've made a syntax error. This is a logic error - you're writing to a document that is already rendered.

 

Do you have past experience programming? If not, I would actually suggest learning PHP before learning Javascript. PHP is more "traditional" and has better documentation. A lot of people, including people who write tutorials, write very poor javascript.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...