function as parameter of a jscript function - how?

  • Thread starter Thread starter José Joye
  • Start date Start date
J

José Joye

Hello,

I'm having problem with my onLoad event of the <a> tag.
In fact, I want to pass as second parameter of my jscript function another
jscript function.
I could not manage to find the correct syntax.

Any hints welcome :-)

José


here is my snippet:

<a href="../Newsletter.htm"
onMouseOver="F_roll('NavButton3',1)"
onMouseOut="F_roll('NavButton3',0)">
<ILAYER ID="NavButton3"></ILAYER>
<img ID="NavButton3" name="NavButton3" height="24" width="100"
src="javascript:F_getImageName('../images/Newsletter',0)"
onLoad="F_loadRollover(this,F_getImageName('./images/Newsletter',1),0)"
border="0" alt="Letter1">
</a>
 
I might be wrong but I don't believe you can use an onload event in an <a> tag because it's
basically a "window" event and needs to be either in the body tag or at the bottom javascript
section as onload="function()"


To make a function run another function nest them and the functions and onload would look like this

<script type="javascript">
function1(){
function info here
function2(){
function info here
}}
onload="function1()"
</script>

However if you want it to be a user initiated event tied to the <a> tag it would be an onclick event
like this:

<a onclick="function1()">

and then

<script type="javascript">
function1(){
function info here
function2(){
function info here
}}
</script>

hth
--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer
 
What's the function F_loadRollover(X,Y) that you are loading w/ image onload look like

--




| Thanks,
|
| You're right, the onload is not part of my <A> tag but of my <img> tag
|
| José
| | > I might be wrong but I don't believe you can use an onload event in an <a>
| tag because it's
| > basically a "window" event and needs to be either in the body tag or at
| the bottom javascript
| > section as onload="function()"
| >
| >
| > To make a function run another function nest them and the functions and
| onload would look like this
| >
| > <script type="javascript">
| > function1(){
| > function info here
| > function2(){
| > function info here
| > }}
| > onload="function1()"
| > </script>
| >
| > However if you want it to be a user initiated event tied to the <a> tag it
| would be an onclick event
| > like this:
| >
| > <a onclick="function1()">
| >
| > and then
| >
| > <script type="javascript">
| > function1(){
| > function info here
| > function2(){
| > function info here
| > }}
| > </script>
| >
| > hth
| > --
| > Steve Easton
| > Microsoft MVP FrontPage
| > 95isalive
| > This site is best viewed............
| > .......................with a computer
| >
| > | > > Hello,
| > >
| > > I'm having problem with my onLoad event of the <a> tag.
| > > In fact, I want to pass as second parameter of my jscript function
| another
| > > jscript function.
| > > I could not manage to find the correct syntax.
| > >
| > > Any hints welcome :-)
| > >
| > > José
| > >
| > >
| > > here is my snippet:
| > >
| > > <a href="../Newsletter.htm"
| > > onMouseOver="F_roll('NavButton3',1)"
| > > onMouseOut="F_roll('NavButton3',0)">
| > > <ILAYER ID="NavButton3"></ILAYER>
| > > <img ID="NavButton3" name="NavButton3" height="24" width="100"
| > > src="javascript:F_getImageName('../images/Newsletter',0)"
| > >
| onLoad="F_loadRollover(this,F_getImageName('./images/Newsletter',1),0)"
| > > border="0" alt="Letter1">
| > > </a>
| > >
| > >
| >
| >
|
|
 
Hello,

This seems to be a standart function I have taken from the web.

I turned aroud the problem wrapping it inside another function that will get
the string first and then call it

Thanks,
José

function F_loadRollover(image,imageName,menu) {
if (image && image.src &&
(null == image.out || typeof(image.out) == typeof(void(0)))) {
s = image.src;
image.out = new Image();
image.out.src = s;
image.over = new Image();
if (imageName.lastIndexOf('/') >= 0 || imageName.lastIndexOf('\\') >= 0) {
s = imageName;
} else {
i = s.lastIndexOf('/');
if (i<0) i = s.lastIndexOf('\\');
if (i<0) { s = imageName; }
else { s = s.substring(0,i+1) + imageName; }
}
image.over.src = s;
image.menu = menu;
loaded[image.name] = image;
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top