Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jan 2007
    Posts
    117
    Thanks
    4
    Thanked 2 Times in 2 Posts

    Add an attribute to the <BODY>

    I want to do an action which causes a postback. The postback checks to see if the action took place. If it did, I want to add an "onload" to the <BODY>. How do I do this?

    The following code will put the attribute in the <FORM>, but it doesn't fire on the postback load.

    Page.Form.Attributes.Add("onload", "OpenFile();")

    There is no "Me.Attributes.Add" - that would be nice.

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,620
    Thanks
    0
    Thanked 645 Times in 635 Posts
    Why put it there when it belongs in the Javascript code.

    window.onload = OpenFile;
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    Regular Coder
    Join Date
    Jan 2007
    Posts
    117
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Because if my action took place, I want to add this function to fire off on my BODY onload on the postback. However, I need to add the onload attribute to the BODY tag. I don't want it to always fire off, only after my "action" has taken place.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •