Wrox Programmer Forums
|
BOOK: Beginning JavaScript
This is the forum to discuss the Wrox book Beginning JavaScript by Paul Wilton; ISBN: 9780764544057
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning JavaScript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 10th, 2005, 08:41 PM
Registered User
 
Join Date: Jan 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default document.onmouseover

I need to capture document.onmouseover to have it fire my function to alter the style of a table, but the code in the book on pg 477 does not seem to be working.
Thanks

The Point of a Journey
Is not to Arrive...
Neil Peart - Rush (Prime Mover)
 
Old January 10th, 2005, 11:12 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

I don't have the book... what is the code on that page and is it throwing any errors?

-Snib - http://www.snibworks.com
Where will you be in 100 years?
 
Old January 11th, 2005, 12:47 AM
Registered User
 
Join Date: Jan 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

the code is in <script>:
document.onmouseover = document_onmouseover;
document.onmouseout = document_onmouseout;

the book says that this will cause the document event to fire the functions: document_onmouseover() and document_onmouseout()

the functions contain td properties RollOver & RollOut and go something like this:

function document_onmouseover()
{
 var srcElement = event.srcElement;
 if (srcElement.tagName == 'td' && typeOf(srcElement.RollOver) != 'undefined')
 {
  srcElement.style.color = "black";
  srcElement.style.backgroundcolor = "grey";
 }
}
function document_onmouseout()
{
 var srcElement = event.srcElement;
 if (srcElement.tagName == "td" && typeOf(srcElement.RollOut) != "undefined")
 {
  srcElement.style.color = "white";
  srcElement.style.backgroundColor = "blue";
 }
}

The Point of a Journey
Is not to Arrive...
Neil Peart - Rush (Prime Mover)
 
Old March 15th, 2005, 06:06 PM
Registered User
 
Join Date: Mar 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Johnscr,

you posted this problem back in November last year, i now find myself up against the exact same issue.

I think the problem lies in the for loop inside the create menu function.

Did you ever find a solution?

Help!!

Thanks
Angela: [email protected]

 
Old March 16th, 2005, 12:41 PM
Registered User
 
Join Date: Jan 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by mcange
 Hi Johnscr,

you posted this problem back in November last year, i now find myself up against the exact same issue.

I think the problem lies in the for loop inside the create menu function.

Did you ever find a solution?

Help!!

Thanks
Angela: [email protected]

The Point of a Journey
Is not to Arrive...
Neil Peart - Rush (Prime Mover)
 
Old March 16th, 2005, 12:51 PM
Registered User
 
Join Date: Jan 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey Angela,
  I did find a solution, I used the onmouseover method on my images to alter the location of the image in the showMenu function. The movement of the image allows the user to know what image they selected. The Function looks like this:

function showMenu(menuToShow)
{
        var srcElement = event.srcElement;
      var xPos = parseInt(srcElement.offsetLeft);
    var yPos = parseInt(srcElement.offsetTop);

    menuToShow.style.left = xPos + (srcElement.width) + 7;
    menuToShow.style.top = yPos;
    srcElement.style.left = 15;
}
function hideMenu(menuToHide)
{
if (event.toElement != menuToHide && menuToHide.contains(event.toElement) == false)
    {
    menuToHide.style.left = -400;
    menuToHide.style.top = -1000;
    document.forms.style.left = 10;
    document.currBasic.style.left = 10;
    document.currFac.style.left = 10;
    document.schedule.style.left = 10;
    document.calendar.style.left = 10;
    document.testOJT.style.left = 10;
    document.zoom.style.left = 10;
    document.requirements.style.left = 10;
    document.resources.style.left = 10;
    }
}
All of the document.***.style.left you see are just to put the table of contents images back in their original locations.
Let me know if you have any questions,

Swiss;)

The Point of a Journey
Is not to Arrive...
Neil Peart - Rush (Prime Mover)
 
Old March 16th, 2005, 12:55 PM
Registered User
 
Join Date: Jan 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I forgot to add that I took out the document.onmouseover code and just used the image related code like, here is an example of one of the images used in the table of contents:

<img border="2" name="currBasic" id="currBasic" src="tocPics/currBasic.bmp" style="position:absolute;left:10;top:80" onmouseover="showMenu(currBasicMenuDiv)" onmouseout="hideMenu(currBasicMenuDiv)" />

Hope this helps,

Swiss

The Point of a Journey
Is not to Arrive...
Neil Peart - Rush (Prime Mover)





Similar Threads
Thread Thread Starter Forum Replies Last Post
onmouseover question??? RinoDM Javascript 3 May 30th, 2008 03:01 AM
onmouseover sstuber BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 April 29th, 2008 12:30 PM
OnMouseOver & OnMouseOut tal Javascript How-To 4 July 19th, 2007 02:29 PM
onMouseOver does not work in FireFox crmpicco Javascript 23 November 9th, 2005 11:15 AM
onmouseover gilgalbiblewheel HTML Code Clinic 4 February 4th, 2005 08:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.