473,573 Members | 2,733 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"onload" method

JS
I have two functions in an external .js page:

createMenu(sel) {
document.write( "TEST1");
}

createFirstMenu (sel){
document.write( "TEST2");
}
I have another page that includes this javaScript. In this page I use <body
onload="createM enu('sel1');">:

<body onload="createM enu('sel1')">
<form name="sels" method="post" action="?page=j ubii">
Kategori:&nbsp; &nbsp;&nbsp;
<select name="sel1" id="sel1" onchange="creat eMenu('sel1','s el2');">
</select>&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;
<select name="sel2" id="sel2">
<option value="" selected
-er- Vælg --</option>

</select>
&nbsp;
<input name="search" type="text" id="search">
&nbsp;
<input type="submit" name="Submit" value="Søg">
</form>

"TEST1" get printed when I open this page as expected.

But if I change onload to:
<body onload="createF irstMenu('sel1' )">

I don't get "TEST2" printed!
What are the explanation?
Jul 23 '05 #1
2 1521
JS

"JS" <dsa.@asdf.co m> skrev i en meddelelse
news:d7******** **@news.net.uni-c.dk...
I have two functions in an external .js page:

createMenu(sel) {
document.write( "TEST1");
}

createFirstMenu (sel){
document.write( "TEST2");
}

I tried to switch the order of the two methods:

createFirstMenu (sel){
document.write( "TEST2");
}

createMenu(sel) {
document.write( "TEST1");
}

And now it works! But I don't know why....is it nessecary to write methods
in a strict order?
Jul 23 '05 #2
JS wrote:
createFirstMenu (sel){
document.write( "TEST2");
}

createMenu(sel) {
document.write( "TEST1");
}

And now it works! But I don't know why....is it nessecary to write methods
in a strict order?


No. Your give example works for me (if I add the word "function" before
each function).

You may give us an URL with an example so we may take a look.

Daniel
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3670
by: TPG | last post by:
I'd like a Javascript function I have written to be invoked whenever *any* new document is been loaded into a particular frame (i.e I don't control the incoming document's BODY tag). Under MSIE5.5, I've found that the ONLOAD handler attribute of the corresponding frame element is invoked *every* time a new document is loaded into that frame....
3
2082
by: kj | last post by:
This problem is driving me nuts. The code at the end of this post below works fine with IE, but fails with Mozilla. You can see it in action at http://tinyurl.com/2jvo3 With Mozilla 1.4 and 1.6, the function msg works fine if it's installed as an onclick handler for the button, but fails as an onload handler for the page. The error is...
3
5747
by: George Hester | last post by:
Nothing. The applet does what it is supposed to do but onload never fires. Any suggestions what may be the problem here? Thanks. -- George Hester __________________________________
4
14332
by: Viken Karaguesian | last post by:
Hello all, I have a question. I trying to run two Javascripts on my webpage, both of which need a <body onload> command. They are as follows: <body onload="runMe()"> <body onload="SwapImgs()"> What would be the proper format to include these on the same line? would it be:
7
6205
by: Calvin KD | last post by:
Hi everyone, Has someone out there experienced the same problem? What i wanted to do is to display a popup window (modal) upon the loading of a webpage. Here is my code sample (in html view): <HTML> <HEAD> .... </HEAD> <BODY onload="ShowPopUp();" MS_POSITIONING="GridLayout"> ....
22
130053
by: stephen | last post by:
I have created an order form that users javascript to create a new html document when the customers clicks the "print page" button. Once the new document has been created it then prints the document and closes it with the following code: <body onload="window.print(); window.close();"> This works correctly (or at least the way I expect...
5
2304
by: tuxedo | last post by:
The way the <body onload="something()"works ensures that the complete html document is loaded before something() is executed. Can the same be achieved when placing the onload call in document somewhere except within the body tag, or must it always be in the body tag? For example, if this is placed elsewhere ... window.onload(something())
1
3792
Cristian Pinheiro
by: Cristian Pinheiro | last post by:
Hello guys, I was playing with Image Thumbnail Viewer (ITV) and found one problem, see http://www.dynamicdrive.com/dynamicindex4/thumbnail.htm for more details and how it works. Now the problem is that the ITV gets executed for the first time on document's onload method. When the page has few thumb images there are no problems. But when...
0
7746
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...
0
7986
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. ...
0
8179
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7736
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...
0
8036
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...
0
6358
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...
1
5556
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...
0
3701
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...
1
2167
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.