p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > Web Programming > JavaScript > Javascript
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript General Javascript discussions.

Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 23rd, 2009, 02:24 AM
Friend of Wrox
Points: 2,244, Level: 19
Points: 2,244, Level: 19 Points: 2,244, Level: 19 Points: 2,244, Level: 19
Activity: 7%
Activity: 7% Activity: 7% Activity: 7%
 
Join Date: Jun 2003
Location: , , Australia.
Posts: 587
Thanks: 1
Thanked 1 Time in 1 Post
Question JS function not seen

Hi All,
I have a typical JS rollover menu that is giving me a Object Expected error.
I am not able to tell what the issue is.
I have simplified things a little to test the code.
So on the mouseover i now call a blanc test function with no parameters and the error still occurs.
I'm really not sure how to debug this any further?
The blow snippet is includes the test function and onmouseover="test();"

The error occuring on the call to the test() function.
I would really appreciate any advise.
Best Regards,
Rod
Code:

function test()
{
alert('boo');
}
</script>
<divstyle="width: 760px; padding: 0px30px0px16px;">
<tablecellpadding="7"cellspacing="7"style="margin-top: -20px;padding-top:10px; padding-right:30px;"align="center"border="0">
<tr>
<td>
<ahref="#"><spanonmouseover="test();onMouseOverMenu(this);"onmouseout="onMouseMenuOut(this);"class="mnuItemNormal">Gallery</span></a>
</td>
Full Menu Code
Code:
<script language="javascript" type="text/javascript">
    function onMouseOverMenu(obj)
    {
        obj.className = 'mnuItemOver';
    }
    
    function onMouseMenuOut(obj)
          
        obj.className = 'mnuItemNormal';        
    }
    function test()
    {
    alert('boo');
    }
</script>     
<div style="width: 760px; padding: 0px 30px 0px 16px;">
    <table cellpadding="7" cellspacing="7" style="margin-top: -20px;padding-top:10px; padding-right:30px;" align="center" border="0" >
        <tr>
            <td>
                <a href="#" ><span onmouseover="test();onMouseOverMenu(this);" onmouseout="onMouseMenuOut(this);" class="mnuItemNormal">Gallery</span></a>
            </td>
            <td>
                <a href="Create.aspx" id="LightWindowLink" class="lightwindow" params="lightwindow_type=external,lightwindow_width=880,lightwindow_height=656"  title="" author="" caption="" >
                     <span class="mnuItemNormal" onmouseover="onMouseOverMenu(this);" onmouseout="onMouseMenuOut(this);">Create one</span></a>
            </td>
            <td class="mnuItemNormal">
                <a href="http://jaal.allaboutlife.com.au/Jesus_has_Answer.aspx" class="mnuItemNormal" target="_parent">
                    <span onmouseover="onMouseOverMenu(this);" onmouseout="onMouseMenuOut(this);"  class="mnuItemNormal"> View TV ad</span></a>
            </td>
            <td class="mnuItemNormal">
                <a href="http://jaal.allaboutlife.com.au/whoisjesus.aspx" class="mnuItemNormal" target="_parent">
                    <span class="mnuItemNormal" onmouseover="onMouseOverMenu(this);" onmouseout="onMouseMenuOut(this);">Who is Jesus</span></a>
            </td>
            <td class="mnuItemNormal">
                <a href="http://jaal.allaboutlife.com.au/Orde...pelofMark.aspx"
                    target="_parent">
                    <span class="mnuItemNormal" onmouseover="onMouseOverMenu(this);" onmouseout="onMouseMenuOut(this);">Gospel Mark</span></a>
            </td>
            <td class="mnuItemNormal">
                <a href="http://jaal.allaboutlife.com.au/whats_on.aspx" target="_parent" >
                    <span onmouseover="onMouseOverMenu(this);" onmouseout="onMouseMenuOut(this);" class="mnuItemNormal">What's On</span></a>
            </td>
            
        </tr>
    </table>
</div>
__________________
======================================
"They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad."
--Shakespeare
======================================
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old October 23rd, 2009, 02:37 AM
Friend of Wrox
Points: 4,805, Level: 29
Points: 4,805, Level: 29 Points: 4,805, Level: 29 Points: 4,805, Level: 29
Activity: 38%
Activity: 38% Activity: 38% Activity: 38%
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,323
Thanks: 3
Thanked 70 Times in 69 Posts
Default

One very minor change and it worked for me:
Code:
    function onMouseMenuOut(obj)
    { /* YOU WERE MISSING THE LEFT BRACE HERE */          
        obj.className = 'mnuItemNormal';        
    }
You know, any decent debugger--or even the stupid ones MS has--would have found that immediately.

I recommend that you start using FireFox with the Firebug plugin. You would have found that in about 5 seconds.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old October 23rd, 2009, 02:39 AM
Friend of Wrox
Points: 4,805, Level: 29
Points: 4,805, Level: 29 Points: 4,805, Level: 29 Points: 4,805, Level: 29
Activity: 38%
Activity: 38% Activity: 38% Activity: 38%
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,323
Thanks: 3
Thanked 70 Times in 69 Posts
Default

Oh, and the "object" that was giving the "object expected" error was indeed that function.

Functions *are* objects in JS, so when the function didn't compile, it didn't exist. Ergo, every time you referenced it..."object expected".
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old October 23rd, 2009, 02:43 AM
Friend of Wrox
Points: 2,244, Level: 19
Points: 2,244, Level: 19 Points: 2,244, Level: 19 Points: 2,244, Level: 19
Activity: 7%
Activity: 7% Activity: 7% Activity: 7%
 
Join Date: Jun 2003
Location: , , Australia.
Posts: 587
Thanks: 1
Thanked 1 Time in 1 Post
Thumbs up

Thanks very much for that.
I had tried that, but in conjunction with other changes, best to start from the beginning I guess.
I didn't write the code and thought I had introduced the missing bracket in my changes.
Many thanks you saved me a heap.
Regards,
Rod
__________________
======================================
"They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad."
--Shakespeare
======================================
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling JS Function from VS? Ron Howerton Javascript 15 September 17th, 2008 03:35 PM
how to run a .js file from a javascript function sbkumar Javascript How-To 1 July 11th, 2008 12:12 PM
passing empty parameters to a js function crmpicco Javascript How-To 0 September 20th, 2005 11:16 AM
function in linked js file 'is not defined' John K. King Javascript 4 May 7th, 2004 10:04 PM
Trigger a JS function on loss of focus apd8x Javascript 1 July 14th, 2003 10:00 AM



All times are GMT -4. The time now is 03:22 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc