Grow your CSS skills. Land your dream job.

load a function on page load

  • # January 28, 2013 at 11:20 am

    hi everyone
    i want to run a function in javascript when page loads. but after loading the page nothing happens! but if i manually refresh the page the function runs! i used these two methods but i dont know where is my problemo! :

    $(window).bind(“load”, function() {
    });
    and this:
    window.onload = showOnEdit;// showOnEdit is my function name

    # January 28, 2013 at 11:40 am

    you can look for when the document is ready:

    $(document).ready(function() {
    //your javascript here…
    }

    or you can do it by calling onload on the body and then your javascript function. you seem to be missing the “” and the () when you call the function. this sould work fine:


    hope this helped..

    # January 28, 2013 at 12:21 pm

    @CarlRosell thanks Carl, i will test “document ready” but i cant test the second one because my site is WordPress.

    # January 28, 2013 at 12:53 pm

    No prob.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".