yoshida Posted October 27, 2007 Share Posted October 27, 2007 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 More sharing options...
Jesdisciple Posted October 27, 2007 Share Posted October 27, 2007 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 More sharing options...
aspnetguy Posted October 27, 2007 Share Posted October 27, 2007 you just call the function like in the example above just after the last element you need to use. Link to comment Share on other sites More sharing options...
yoshida Posted October 28, 2007 Author Share Posted October 28, 2007 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.