|
|
 |
| 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.
|
 |

October 23rd, 2009, 02:24 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: , , Australia.
Posts: 587
Thanks: 1
Thanked 1 Time in 1 Post
|
|
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
======================================
|

October 23rd, 2009, 02:37 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,323
Thanks: 3
Thanked 70 Times in 69 Posts
|
|
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.
|

October 23rd, 2009, 02:39 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,323
Thanks: 3
Thanked 70 Times in 69 Posts
|
|
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".
|

October 23rd, 2009, 02:43 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: , , Australia.
Posts: 587
Thanks: 1
Thanked 1 Time in 1 Post
|
|
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
======================================
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |