?
Solved

Calling a javascript function

Posted on 2006-06-08
2
Medium Priority
?
150 Views
Last Modified: 2010-05-18
Hello,

How would I call a javascript function WITHOUT clicking a button. I have seen several examples where the function concerned
is called by onClick, by attaching to a button. I do not need that. In my case, my program checks for a condition and if a certain
condition is not satisfied, I want to popup a message. How would I do this?

prain
0
Comment
Question by:prain
  • 2
2 Comments
 
LVL 54

Accepted Solution

by:
b0lsc0tt earned 300 total points
ID: 16864191
prain,

I feel the most common way would be to use the onLoad attribute of the body tag.  Reference a JavaScript function that you have placed in the head section of the page.  This is the method I would suggest with the details you provided.

An example of a body tag with the attribute I mentioned is below:

<body onload="testpage()">

The onload could contain the code itself or reference a function (my example used testpage) that you placed in the head section or even in the body.  Let me know if you need more information or have a question.

b0lsc0tt
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 16865197
I'm glad that I could help.  Thanks for the grade, the points and the fun question.

bol
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question