473,779 Members | 2,058 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple functions on window.onload

74 New Member
Hi there!

I'm developing some crazy Tab Control in .NET that uses JavaScript.

A particular JavaScript method needs to be called during the window.onload event in order to initialize my Tab Control.

The thing is that there can be more than one Tab Control on the page....and each one must be initialized during the window.onload event.

Adding the JavaScript function call responsible for initializing a particular Tab Control to the function that the window.onload calls is impossible using .NET (I've tried to do this for 4 days now...)

For Example:
This is not possible to do from a .NET standpoint:
Expand|Select|Wrap|Line Numbers
  1.  
  2. <script type="text/javascript">
  3. <!--
  4. window.onload = function() {
  5.  
  6. /*This Is Not Possible*/
  7. eval(TabControl1_intializeTabbedControls());
  8. eval(TabControl2_intializeTabbedControls());
  9. eval(TabControl3_intializeTabbedControls());
  10. /*.....................*/
  11. }// -->
  12. </script>
  13.  
This is possible to do from a .NET standpoint but obviously won't work in javascript:
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. <!--window.onload = function() {eval(TabControl1_intializeTabbedControls());}//-->
  3. </script>
  4.  
  5. <script type="text/javascript">
  6. <!--window.onload = function() {eval(TabControl2_intializeTabbedControls());}//-->
  7. </script>
  8.  
  9. <script type="text/javascript">
  10. <!--window.onload = function() {eval(TabControl3_intializeTabbedControls());}//-->
  11. </script>
  12.  
Basically I'd like to call the window.onload more than once...but this isn't possible...so I'm open to any other suggestions...

Does anyone have any suggestions on how to do this?

Thanks for your time

-lilolme
Sep 5 '07 #1
5 9482
acoder
16,027 Recognized Expert Moderator MVP
Try using addEventListene r (W3C standard) and attachEvent (IE). See this article (the events part). Also see this link for an explanation.

PS. changed the thread title slightly.
Sep 5 '07 #2
lilOlMe
74 New Member
Try using addEventListene r (W3C standard) and attachEvent (IE). See this article (the events part). Also see this link for an explanation.

PS. changed the thread title slightly.
Acoder, you're a lifesaver!!
Thank you so much for that quicksmode link!
You've helped me immensely!
Every thing's working well in browsers that are not IE :):)

IE will load the page properly ...except that for some reason I'm getting a "Type Mismatch" error. The line number that IE says the error occur on just contains a <tr>...and the vagueness of the error is not helping me at all.

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. <!--
  3. if(window.attachEvent){
  4.     window.attachEvent("onload",TabControl1_intializeTabbedControls());
  5. }else{    
  6.     window.addEventListener("load",TabControl1_intializeTabbedControls(),false);
  7. }
  8. // -->
  9. </script>
  10.  
  11. <script type="text/javascript">
  12. <!--
  13. if(window.attachEvent){
  14.     window.attachEvent("onload",TabControl2_intializeTabbedControls());
  15. }else{   
  16.     window.addEventListener("load",TabControl2_intializeTabbedControls(),false);
  17. }
  18. // -->
  19. </script>
  20.  
Do you have any insight as to why this might be occurring?
Thank you for being so patient with me :) JavaScript is not one of my strong points.

-LilOlMe
Sep 6 '07 #3
acoder
16,027 Recognized Expert Moderator MVP
Remove the parentheses when attaching/adding event listeners:
Expand|Select|Wrap|Line Numbers
  1. if(window.attachEvent){
  2.     window.attachEvent("onload",TabControl1_intializeTabbedControls);
  3. }else{   
  4.     window.addEventListener("load",TabControl1_intializeTabbedControls,false);
  5. }
If that doesn't work, show the code for the tab control function.
Sep 6 '07 #4
lilOlMe
74 New Member
Remove the parentheses when attaching/adding event listeners:
Expand|Select|Wrap|Line Numbers
  1. if(window.attachEvent){
  2.     window.attachEvent("onload",TabControl1_intializeTabbedControls);
  3. }else{   
  4.     window.addEventListener("load",TabControl1_intializeTabbedControls,false);
  5. }
If that doesn't work, show the code for the tab control function.
Thanks Again!

I removed the () and everything works perfectly now :)

Wish I had asked my question earlier!


-LilOlMe
Sep 6 '07 #5
acoder
16,027 Recognized Expert Moderator MVP
Glad you got it working. Post again anytime should you hit some problem.
Sep 6 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
6821
by: Da Costa Gomez | last post by:
Hi all, I've been eluded the last couple of *days* on the onload mystery within the frame and function context. Problem is as follows: - frameset with two frames. One called scripts and the other called main - scripts carries a bunch of js functions rechable via parent.scripts.functioName() - Main carries the html page that utilizes some functions
3
2002
by: Disco-181 | last post by:
Hi, I have a script which isn't working in Mozilla based browser for some reason. I'm trying to run two functions from the body onload tag and it simply isn't happening. I have a cascading menu, where the primary dropdown selection determines the contents of a second dropdown. This is triggered by a function in the onchange tag of the primarys select tag. When triggered like this, the function and drop downs work fine. When
2
2428
by: John J. Lee | last post by:
I was cheered to see that this guy claims to have solved the problem with onload only firing very late: http://dean.edwards.name/weblog/2005/09/busted/ However, "ash" comments on that page:
4
2478
by: Matt Ratliff | last post by:
Hello, I would appreciate any assistance you have with the following problem: I have (as an example) an array of values as follows: arrayvalues=new Array("0001","0003","0005") where each is the value of an option in a select statement: <select id="usertypes" multiple="multiple"> <option value="0033">data1</option>
3
1257
by: Lorenzo Thurman | last post by:
Is there a shorthand way to assign the same actions to multiple handlers ? I know I can just just do: onBlur='myFunction()';onClick='myFunction()' I'm just looking to save some keystrokes. I actually have this issue now and it involves a couple of functions with long parameter lists. TIA
5
6161
by: steve.chambers | last post by:
I'm sure this q must have been asked before but I'm really struggling to find the answer anywhere so have finally given up and will consult the usenet community - hopefully there's someone out there who's seen it all before and can help me out! I have a webpage which needs to make some function calls after the page has loaded - won't go into details surfice to say here is a code fragment: function addLoadEvent(func) { var oldonload =...
6
4690
by: Michael Landberg | last post by:
Hi is it possible to load multiple onload events in the body tag? Regards
3
2081
by: zepdad | last post by:
I'm new to forum and am learning javascript. I appreciate your help and patience in advance. I run an image gallery website that uses an onload event called FitPic() to scale image and window sizes to fit the users monitor resolution. FitPic() creates certain variables that would be useful for other calculations, such as reporting the % of image scaling. However, since onload events occur last during rendering, the variables are not...
2
1909
by: Calm_Pear | last post by:
Hi all, I have created an object with a default function; the default function exposes a public function as well. myobject = function(){
0
9636
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10306
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9930
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8961
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6724
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2869
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.