Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To 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 6th, 2006, 06:45 AM
Authorized User
Join Date: Mar 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problems with Body onload event

Hi there

I've just realised that the onload event is only valid for <body> and <frameset> after trying to validate my new website!

So, I have tried to incorporate the onload event I previously had on a 1 pixel invisible gif into the body tag, but Dreamweaver keeps crashing every time I try, so I'm guessing I've got it wrong!

My website has an expandable menu which uses javascript to open and close submenus acording to my CSS style sheet. This works OK and validates fine.
My problems occurs when I try to set my breadcrumbs to open and close these submenus according to where in the site you navigate to. The image onload event works fine, but will not pass W3 validation.

Has anyone got an idea as to how I can assign this function to the body tag?

Here's the ASP with the event:

    Dim strMenuHold
    Dim strMenuPos
    Dim strMenuText
        Dim DQ

        DQ = """"

    strMenuText = arrstrSplit(1)

    Select Case strMenuText
        Case "Undergraduate"
            strMenuPos = "0"
        Case "Postgraduate"
            strMenuPos = "1"
        Case "Research"
            strMenuPos = "2"
        Case "Companies"
            strMenuPos = "3"
        Case "FAQ"
            strMenuPos = ""
        Case "Us"
            strMenuPos = "4"
        Case "Events"
            strMenuPos = "5"
    End Select

'//////Build strMenuHold to open correct part of menu///////

    If StrMenuPos <> "" then
        strMenuHold = "<Img src=" & DQ & "/shprsdev/images/small.gif" & DQ & " alt=" & DQ & " " & DQ & " width=" & DQ & "1" & DQ & " height=" & DQ & "1" & DQ & " onLoad=" & DQ & "expandMenu(" & strMenuPos & "); return false;" & DQ & ">"
    End If


Hope someone can help!


Similar Threads
Thread Thread Starter Forum Replies Last Post
Invoke onClick() function when body onLoad muklee Javascript How-To 2 March 16th, 2007 01:02 AM
Double DB insert using body.onload needlz BOOK: Professional Ajax ISBN: 978-0-471-77778-6 1 February 20th, 2006 04:18 PM
Accessing the value of a Cell in Onload event asdasd Javascript 1 February 19th, 2005 04:50 AM
Body Onload Function Question apd8x Javascript 2 July 10th, 2003 02:52 AM

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