Jump to content

stupid n00b question


yoshida
 Share

Recommended Posts

This may be a stupid n00b question, but how do I call a javascript function without using an event trigger? I'd like to populate some divs with data, both the source data and the target divs defined by a parameter. That means I have to call the function, an XmlHttpRequest, multiple times.I'll search my library for answers, helpful suggestions are welcome in the meantime.

Link to comment
Share on other sites

You can do this:

<html>	<head>		<title>Titled Document</title>		<script type="text/javascript">			function main(){				alert('I\'m in...');			}			main();		</script>	</head>	<body>	</body></html>

The problem with this method is that the page isn't loaded, and page elements aren't available when main() is called. (Why must you avoid using event handlers?)Does anyone else have another way?

Link to comment
Share on other sites

Here I am looking for the long way around...I thought of creating an array, and have it populate the page using a WHILE loop. But I bashed my head against the wall in stupidity after two lines of code.I used PHP for this one instead, opening the specified DIV, call <?php require_once('script.php') ?> and closed the DIV.It's the easiest way since it's a management page for my new CMS after all.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...