By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,628 Members | 1,880 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,628 IT Pros & Developers. It's quick & easy.

dw preload function

P: n/a
hi everybody

let me say right from the start .. I┤m not a coder ... "just" a designer!
that said .. here is my question:

I┤m using dreamweaver┤s built in preloader for a menu. it looks like this:

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length;
i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

Then, in the body tag you have the preload:

<body onload="MM_preloadimages('/images/image1.jpg','/images/image2.jpg')">

But I don┤t want the function calls to be in the file itself, BUT linked to
an extenal js file.

can you PLEASE tell me how to do it?? (using this confusing dw
code -mm_preloadimages that is-)
--

--------------------------------------
Part of the "No Signature Movement"
My site: http://www.webbasica.com
And for all those spammers out there,
knock yourself out:
ma*****@webbasica.com
Jul 20 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
MALdito wrote:
let me say right from the start .. I┤m not a coder ... "just" a designer!
Well, *become* a coder.
I┤m using dreamweaver┤s built in preloader for a menu. it looks like this:

function MM_preloadImages() { //v3.0
[...]
}
What a line-optimized trash. I know why I'm not using DW anymore.
Then, in the body tag
You mean the start tag of the `body' element.
you have the preload:

<body onload="MM_preloadimages('/images/image1.jpg','/images/image2.jpg')">

But I don┤t want the function calls to be in the file itself, BUT linked to
an extenal js file.
Do it then and use

<script src="foobar.js" type="text/javascript"></script>

somewhere within the `head' element.
can you PLEASE tell me how to do it?? (using this confusing dw
code -mm_preloadimages that is-)


Preloading images is a Bad Thing because you let people download data they
don't requested and most certainly won't need. Even if the caching does the
trick (which isn't for sure since you can't change the cache settings on the
client,) it slows your website down in the beginning, so most certainly
neither you nor the user will have any benefit from it. Let it be.
PointedEars

Jul 20 '05 #2

P: n/a
You will need to create a .js file with the function in it

eg whatever.js

Then attach the .js file to whichever pages / files you want to use it

<script src="whatever.js"></script>

then all you need to do is call the function by using

MM_preloadimages('im/im1.jpg','im/im2.jpg')

etc - the function will automatically detect how many images you are trying
to preload,

unfortunately there are too many people like Thomas Lahn, too eager to
brag - to slow to assist.

Hope this helps

Simon Christie
"MALdito" <ma*****@webbasica.com> wrote in message
news:bn************@ID-122517.news.uni-berlin.de...
hi everybody

let me say right from the start .. I┤m not a coder ... "just" a designer!
that said .. here is my question:

I┤m using dreamweaver┤s built in preloader for a menu. it looks like this:

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
Then, in the body tag you have the preload:

<body onload="MM_preloadimages('/images/image1.jpg','/images/image2.jpg')">
But I don┤t want the function calls to be in the file itself, BUT linked to an extenal js file.

can you PLEASE tell me how to do it?? (using this confusing dw
code -mm_preloadimages that is-)
--

--------------------------------------
Part of the "No Signature Movement"
My site: http://www.webbasica.com
And for all those spammers out there,
knock yourself out:
ma*****@webbasica.com

Jul 20 '05 #3

P: n/a
Well thanks Simone!!

I understood everything you said, and now I will try to explain exactly what
I need...

I need to "put" the calling functions in a linked file .. maybe even in the
js itself. Actually, the first part (the js) can stay in the html. But the
call functions has be external and then linked. Why? cause then, if i wanna
add more sections to my site, the process will become really easier .. since
all my layout is beeing done with ssi and linked stuff..

So, what i need is (in lesser words) .. how to put the calling functions
(MM_preloadimages) in a remote file? and for that matter .. how to should
the remote js be? just copy and paste the js i have in the html right now,
and name it whatever.js ? using the same syntax??

thanks a lot for all the help

ps: to the pointedears guy .. thanks, your pointless typing is what made
simone help me ..
"steve stevo" <st***@stevosteve.fsnet.co.uk> escribiˇ en el mensaje
news:bn**********@newsg1.svr.pol.co.uk...
You will need to create a .js file with the function in it

eg whatever.js

Then attach the .js file to whichever pages / files you want to use it

<script src="whatever.js"></script>

then all you need to do is call the function by using

MM_preloadimages('im/im1.jpg','im/im2.jpg')

etc - the function will automatically detect how many images you are trying to preload,

unfortunately there are too many people like Thomas Lahn, too eager to
brag - to slow to assist.

Hope this helps

Simon Christie
"MALdito" <ma*****@webbasica.com> wrote in message
news:bn************@ID-122517.news.uni-berlin.de...
hi everybody

let me say right from the start .. I┤m not a coder ... "just" a designer! that said .. here is my question:

I┤m using dreamweaver┤s built in preloader for a menu. it looks like this:
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0;

i<a.length;
i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image;

d.MM_p[j++].src=a[i];}}

Then, in the body tag you have the preload:

<body

onload="MM_preloadimages('/images/image1.jpg','/images/image2.jpg')">

But I don┤t want the function calls to be in the file itself, BUT linked

to
an extenal js file.

can you PLEASE tell me how to do it?? (using this confusing dw
code -mm_preloadimages that is-)
--

--------------------------------------
Part of the "No Signature Movement"
My site: http://www.webbasica.com
And for all those spammers out there,
knock yourself out:
ma*****@webbasica.com


Jul 20 '05 #4

P: n/a
I think I can see what you're on about - you want to preload the same images
x amount of times ?

Lets look at the external .js file contents :

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length;
i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image;
d.MM_p[j++].src=a[i];}}
At the moment you have an event to call the javascript :

<body onload="MM_preloadimages('/images/image1.jpg','/images/image2.jpg')">

the event is the onload event

but a function does not need an event to run - if you just placed

MM_preloadimages('/images/image1.jpg','/images/image2.jpg')

within the <script> tags, the function would also run just the same - it
would also run the same if it were also in an external file

eg

<script src="MM_Preload_Function.js"><script> // has the preload function in
it
<script src="MM_Preload_Function_Call.js"><script> // has the function call
in it

remember that when functions aren't called by events, thye will run as page
is loaded, therefore you will need to load the function b4 you can call it.
HTH

Simon Christie

PS - its Simon not Simone


"MALdito" <ma*****@webbasica.com> wrote in message
news:bn************@ID-122517.news.uni-berlin.de...
Well thanks Simone!!

I understood everything you said, and now I will try to explain exactly what I need...

I need to "put" the calling functions in a linked file .. maybe even in the js itself. Actually, the first part (the js) can stay in the html. But the
call functions has be external and then linked. Why? cause then, if i wanna add more sections to my site, the process will become really easier .. since all my layout is beeing done with ssi and linked stuff..

So, what i need is (in lesser words) .. how to put the calling functions
(MM_preloadimages) in a remote file? and for that matter .. how to should
the remote js be? just copy and paste the js i have in the html right now,
and name it whatever.js ? using the same syntax??

thanks a lot for all the help

ps: to the pointedears guy .. thanks, your pointless typing is what made
simone help me ..
"steve stevo" <st***@stevosteve.fsnet.co.uk> escribiˇ en el mensaje
news:bn**********@newsg1.svr.pol.co.uk...
You will need to create a .js file with the function in it

eg whatever.js

Then attach the .js file to whichever pages / files you want to use it

<script src="whatever.js"></script>

then all you need to do is call the function by using

MM_preloadimages('im/im1.jpg','im/im2.jpg')

etc - the function will automatically detect how many images you are

trying
to preload,

unfortunately there are too many people like Thomas Lahn, too eager to
brag - to slow to assist.

Hope this helps

Simon Christie
"MALdito" <ma*****@webbasica.com> wrote in message
news:bn************@ID-122517.news.uni-berlin.de...
hi everybody

let me say right from the start .. I┤m not a coder ... "just" a designer! that said .. here is my question:

I┤m using dreamweaver┤s built in preloader for a menu. it looks like this:
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0;

i<a.length;
i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image;

d.MM_p[j++].src=a[i];}}

Then, in the body tag you have the preload:

<body

onload="MM_preloadimages('/images/image1.jpg','/images/image2.jpg')">

But I don┤t want the function calls to be in the file itself, BUT
linked to
an extenal js file.

can you PLEASE tell me how to do it?? (using this confusing dw
code -mm_preloadimages that is-)
--

--------------------------------------
Part of the "No Signature Movement"
My site: http://www.webbasica.com
And for all those spammers out there,
knock yourself out:
ma*****@webbasica.com



Jul 20 '05 #5

P: n/a
Sorry about the name ..

Simon, so it would be ok if i put the js into an external file PLUS the
function-call? what would be the syntax?

MM_preloadimages('/images/image1.jpg','/images/image2.jpg')

no ; or } at the end??

thanks!

"steve stevo" <st***@stevosteve.fsnet.co.uk> escribiˇ en el mensaje
news:bn**********@news7.svr.pol.co.uk...
I think I can see what you're on about - you want to preload the same images x amount of times ?

Lets look at the external .js file contents :

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image;
d.MM_p[j++].src=a[i];}}
At the moment you have an event to call the javascript :

<body onload="MM_preloadimages('/images/image1.jpg','/images/image2.jpg')">
the event is the onload event

but a function does not need an event to run - if you just placed

MM_preloadimages('/images/image1.jpg','/images/image2.jpg')

within the <script> tags, the function would also run just the same - it
would also run the same if it were also in an external file

eg

<script src="MM_Preload_Function.js"><script> // has the preload function in it
<script src="MM_Preload_Function_Call.js"><script> // has the function call in it

remember that when functions aren't called by events, thye will run as page is loaded, therefore you will need to load the function b4 you can call it.

HTH

Simon Christie

PS - its Simon not Simone


"MALdito" <ma*****@webbasica.com> wrote in message
news:bn************@ID-122517.news.uni-berlin.de...
Well thanks Simone!!

I understood everything you said, and now I will try to explain exactly

what
I need...

I need to "put" the calling functions in a linked file .. maybe even in

the
js itself. Actually, the first part (the js) can stay in the html. But the
call functions has be external and then linked. Why? cause then, if i

wanna
add more sections to my site, the process will become really easier ..

since
all my layout is beeing done with ssi and linked stuff..

So, what i need is (in lesser words) .. how to put the calling functions
(MM_preloadimages) in a remote file? and for that matter .. how to should the remote js be? just copy and paste the js i have in the html right now, and name it whatever.js ? using the same syntax??

thanks a lot for all the help

ps: to the pointedears guy .. thanks, your pointless typing is what made
simone help me ..
"steve stevo" <st***@stevosteve.fsnet.co.uk> escribiˇ en el mensaje
news:bn**********@newsg1.svr.pol.co.uk...
You will need to create a .js file with the function in it

eg whatever.js

Then attach the .js file to whichever pages / files you want to use it

<script src="whatever.js"></script>

then all you need to do is call the function by using

MM_preloadimages('im/im1.jpg','im/im2.jpg')

etc - the function will automatically detect how many images you are

trying
to preload,

unfortunately there are too many people like Thomas Lahn, too eager to
brag - to slow to assist.

Hope this helps

Simon Christie
"MALdito" <ma*****@webbasica.com> wrote in message
news:bn************@ID-122517.news.uni-berlin.de...
> hi everybody
>
> let me say right from the start .. I┤m not a coder ... "just" a

designer!
> that said .. here is my question:
>
> I┤m using dreamweaver┤s built in preloader for a menu. it looks like

this:
>
> function MM_preloadImages() { //v3.0
> var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
> var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0;
i<a.length;
> i++)
> if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image;
d.MM_p[j++].src=a[i];}}
>
> Then, in the body tag you have the preload:
>
> <body
onload="MM_preloadimages('/images/image1.jpg','/images/image2.jpg')">
>
> But I don┤t want the function calls to be in the file itself, BUT

linked to
> an extenal js file.
>
> can you PLEASE tell me how to do it?? (using this confusing dw
> code -mm_preloadimages that is-)
>
>
> --
>
> --------------------------------------
> Part of the "No Signature Movement"
> My site: http://www.webbasica.com
> And for all those spammers out there,
> knock yourself out:
> ma*****@webbasica.com
>
>



Jul 20 '05 #6

P: n/a
The best way is to try and see

the correct syntax would be

MM_preloadimages('/images/image1.jpg','/images/image2.jpg');

the ; signifies end of statement
the curly brackets are used to define segments of a function

eg
function test(){
if(true){
alert("yippee");
}else{
alert("boohoo");
}
}

Hope this helps

Simon Christie
"MALdito" <ma*****@webbasica.com> wrote in message
news:bn************@ID-122517.news.uni-berlin.de...
Sorry about the name ..

Simon, so it would be ok if i put the js into an external file PLUS the
function-call? what would be the syntax?

MM_preloadimages('/images/image1.jpg','/images/image2.jpg')

no ; or } at the end??

thanks!

"steve stevo" <st***@stevosteve.fsnet.co.uk> escribiˇ en el mensaje
news:bn**********@news7.svr.pol.co.uk...
I think I can see what you're on about - you want to preload the same images
x amount of times ?

Lets look at the external .js file contents :

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0;

i<a.length;
i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image;
d.MM_p[j++].src=a[i];}}
At the moment you have an event to call the javascript :

<body

onload="MM_preloadimages('/images/image1.jpg','/images/image2.jpg')">

the event is the onload event

but a function does not need an event to run - if you just placed

MM_preloadimages('/images/image1.jpg','/images/image2.jpg')

within the <script> tags, the function would also run just the same - it
would also run the same if it were also in an external file

eg

<script src="MM_Preload_Function.js"><script> // has the preload function in
it
<script src="MM_Preload_Function_Call.js"><script> // has the function

call
in it

remember that when functions aren't called by events, thye will run as

page
is loaded, therefore you will need to load the function b4 you can call

it.


HTH

Simon Christie

PS - its Simon not Simone


"MALdito" <ma*****@webbasica.com> wrote in message
news:bn************@ID-122517.news.uni-berlin.de...
Well thanks Simone!!

I understood everything you said, and now I will try to explain exactly
what
I need...

I need to "put" the calling functions in a linked file .. maybe even
in the
js itself. Actually, the first part (the js) can stay in the html. But

the call functions has be external and then linked. Why? cause then, if i

wanna
add more sections to my site, the process will become really easier ..

since
all my layout is beeing done with ssi and linked stuff..

So, what i need is (in lesser words) .. how to put the calling
functions (MM_preloadimages) in a remote file? and for that matter .. how to

should the remote js be? just copy and paste the js i have in the html right now, and name it whatever.js ? using the same syntax??

thanks a lot for all the help

ps: to the pointedears guy .. thanks, your pointless typing is what made simone help me ..
"steve stevo" <st***@stevosteve.fsnet.co.uk> escribiˇ en el mensaje
news:bn**********@newsg1.svr.pol.co.uk...
> You will need to create a .js file with the function in it
>
> eg whatever.js
>
> Then attach the .js file to whichever pages / files you want to use it >
> <script src="whatever.js"></script>
>
> then all you need to do is call the function by using
>
> MM_preloadimages('im/im1.jpg','im/im2.jpg')
>
> etc - the function will automatically detect how many images you are
trying
> to preload,
>
> unfortunately there are too many people like Thomas Lahn, too eager to > brag - to slow to assist.
>
> Hope this helps
>
> Simon Christie
>
>
> "MALdito" <ma*****@webbasica.com> wrote in message
> news:bn************@ID-122517.news.uni-berlin.de...
> > hi everybody
> >
> > let me say right from the start .. I┤m not a coder ... "just" a
designer!
> > that said .. here is my question:
> >
> > I┤m using dreamweaver┤s built in preloader for a menu. it looks like this:
> >
> > function MM_preloadImages() { //v3.0
> > var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
> > var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0;
> i<a.length;
> > i++)
> > if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image;
> d.MM_p[j++].src=a[i];}}
> >
> > Then, in the body tag you have the preload:
> >
> > <body
> onload="MM_preloadimages('/images/image1.jpg','/images/image2.jpg')"> > >
> > But I don┤t want the function calls to be in the file itself, BUT

linked
> to
> > an extenal js file.
> >
> > can you PLEASE tell me how to do it?? (using this confusing dw
> > code -mm_preloadimages that is-)
> >
> >
> > --
> >
> > --------------------------------------
> > Part of the "No Signature Movement"
> > My site: http://www.webbasica.com
> > And for all those spammers out there,
> > knock yourself out:
> > ma*****@webbasica.com
> >
> >
>
>



Jul 20 '05 #7

P: n/a
well ... you did it!

thanks a lot

m.
"steve stevo" <st***@stevosteve.fsnet.co.uk> escribiˇ en el mensaje
news:bn**********@newsg1.svr.pol.co.uk...
The best way is to try and see

the correct syntax would be

MM_preloadimages('/images/image1.jpg','/images/image2.jpg');

the ; signifies end of statement
the curly brackets are used to define segments of a function

eg
function test(){
if(true){
alert("yippee");
}else{
alert("boohoo");
}
}

Hope this helps

Simon Christie
"MALdito" <ma*****@webbasica.com> wrote in message
news:bn************@ID-122517.news.uni-berlin.de...
Sorry about the name ..

Simon, so it would be ok if i put the js into an external file PLUS the
function-call? what would be the syntax?

MM_preloadimages('/images/image1.jpg','/images/image2.jpg')

no ; or } at the end??

thanks!

"steve stevo" <st***@stevosteve.fsnet.co.uk> escribiˇ en el mensaje
news:bn**********@news7.svr.pol.co.uk...
I think I can see what you're on about - you want to preload the same images
x amount of times ?

Lets look at the external .js file contents :

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0;

i<a.length;
i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image;
d.MM_p[j++].src=a[i];}}
At the moment you have an event to call the javascript :

<body

onload="MM_preloadimages('/images/image1.jpg','/images/image2.jpg')">

the event is the onload event

but a function does not need an event to run - if you just placed

MM_preloadimages('/images/image1.jpg','/images/image2.jpg')

within the <script> tags, the function would also run just the same - it would also run the same if it were also in an external file

eg

<script src="MM_Preload_Function.js"><script> // has the preload function
in
it
<script src="MM_Preload_Function_Call.js"><script> // has the function

call
in it

remember that when functions aren't called by events, thye will run as

page
is loaded, therefore you will need to load the function b4 you can call
it.


HTH

Simon Christie

PS - its Simon not Simone


"MALdito" <ma*****@webbasica.com> wrote in message
news:bn************@ID-122517.news.uni-berlin.de...
> Well thanks Simone!!
>
> I understood everything you said, and now I will try to explain exactly what
> I need...
>
> I need to "put" the calling functions in a linked file .. maybe even in the
> js itself. Actually, the first part (the js) can stay in the html.
But the
> call functions has be external and then linked. Why? cause then, if
i wanna
> add more sections to my site, the process will become really easier ... since
> all my layout is beeing done with ssi and linked stuff..
>
> So, what i need is (in lesser words) .. how to put the calling

functions > (MM_preloadimages) in a remote file? and for that matter .. how to

should
> the remote js be? just copy and paste the js i have in the html right now,
> and name it whatever.js ? using the same syntax??
>
> thanks a lot for all the help
>
> ps: to the pointedears guy .. thanks, your pointless typing is what made > simone help me ..
>
>
> "steve stevo" <st***@stevosteve.fsnet.co.uk> escribiˇ en el mensaje
> news:bn**********@newsg1.svr.pol.co.uk...
> > You will need to create a .js file with the function in it
> >
> > eg whatever.js
> >
> > Then attach the .js file to whichever pages / files you want to
use it > >
> > <script src="whatever.js"></script>
> >
> > then all you need to do is call the function by using
> >
> > MM_preloadimages('im/im1.jpg','im/im2.jpg')
> >
> > etc - the function will automatically detect how many images you
are > trying
> > to preload,
> >
> > unfortunately there are too many people like Thomas Lahn, too eager
to > > brag - to slow to assist.
> >
> > Hope this helps
> >
> > Simon Christie
> >
> >
> > "MALdito" <ma*****@webbasica.com> wrote in message
> > news:bn************@ID-122517.news.uni-berlin.de...
> > > hi everybody
> > >
> > > let me say right from the start .. I┤m not a coder ... "just" a
> designer!
> > > that said .. here is my question:
> > >
> > > I┤m using dreamweaver┤s built in preloader for a menu. it looks like > this:
> > >
> > > function MM_preloadImages() { //v3.0
> > > var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
> > > var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0;
> > i<a.length;
> > > i++)
> > > if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image;
> > d.MM_p[j++].src=a[i];}}
> > >
> > > Then, in the body tag you have the preload:
> > >
> > > <body
> > onload="MM_preloadimages('/images/image1.jpg','/images/image2.jpg')"> > > >
> > > But I don┤t want the function calls to be in the file itself,

BUT linked
> > to
> > > an extenal js file.
> > >
> > > can you PLEASE tell me how to do it?? (using this confusing dw
> > > code -mm_preloadimages that is-)
> > >
> > >
> > > --
> > >
> > > --------------------------------------
> > > Part of the "No Signature Movement"
> > > My site: http://www.webbasica.com
> > > And for all those spammers out there,
> > > knock yourself out:
> > > ma*****@webbasica.com
> > >
> > >
> >
> >
>
>



Jul 20 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.