/    Sign up×
Community /Pin to ProfileBookmark

How can I add this:

[CODE]
image = new Image()
image.src = “something.gif”
[/CODE]

to this:

[code]
<!–
var imagenames=[ ‘http://www.crosspoint.org/logo.png’ ,
];

var loadedcolor=’#000080′ ; // COLOR
var unloadedcolor=’#D3DDF5′; // BGCOLOR OF UNLOADED AREA
var barheight=25; // HEIGHT IN PIXELS
var barwidth=400; // WIDTH IN PIXELS
var bordercolor=’#000080′; // BORDER COLOR
var textColor=’white’; // COLOR OF TEXT IN LOADING BAR
var textSize=’12px’; // SIZE OF TEXT IN LOADING BAR
var textFont=’verdana’; // FONT FAMILY OF TEXT IN LOADING BAR
var loadonce=false; // IF THIS VALUE IS true THE BAR WILL NOT DISPLAY IF THE USER
// RETURNS TO THE PAGE, SET TO false TO HAVE THE BAR REAPPEAR IF
// THE USER RETURNS TO THE PAGE.

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var action=function()
{
document.location.href=”http://www.crosspoint.org/picturesMAIN.html”
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

var NS4 = (document.layers)? true : false;
var IE4 = (document.all)? true : false;
var blocksize=(barwidth-2)/(imagenames.length);
barheight=Math.max(barheight,4);
var loaded=0;
var perouter=null;
var perdone=null;
var images=new Array();
var txt=”;
if(NS4){
txt+='<table cellspacing=0 cellpadding=0 border=0><tr><td>’;
txt+='<ilayer name=”perouter” visibility=”hide” height=”‘+barheight+'” width=”‘+barwidth+'”>’;
txt+='<layer width=”‘+barwidth+'” height=”‘+barheight+'” bgcolor=”‘+bordercolor+'” top=”0″ left=”0″></layer>’;
txt+='<layer width=”‘+(barwidth-2)+'” height=”‘+(barheight-2)+'” bgcolor=”‘+unloadedcolor+'” top=”1″ left=”1″></layer>’;
txt+='<layer name=”perdone” width=”‘+(barwidth-2)+'” height=”‘+(barheight-2)+'” bgcolor=”‘+loadedcolor+'” top=”1″ left=”1″></layer>’;
txt+='<layer width=”‘+(barwidth-2)+'” height=”‘+(barheight-2)+'” top=”1″ left=”1″>’;
txt+='<table cellpadding=0 cellspacing=0 border=0 width=”‘+(barwidth-2)+'” height=”‘+(barheight-2)+'”><tr><td align=”center” valign=”middle”>’;
txt+='<span style=”color:’+textColor+’; font-size:’+textSize+’; font-family:’+textFont+'”>Processing… (click to dismiss)</span>’;
txt+='</td></tr></table>’;
txt+='</layer>’;
txt+='</ilayer>’;
txt+='</td></tr></table>’;
}else{
txt+='<div id=”perouter” style=”position:relative; visibility:hidden; background-color:’+bordercolor+’; width:’+barwidth+’px; height:’+barheight+’px;”>’;
txt+='<div style=”position:absolute; top:1px; left:1px; width:’+(barwidth-2)+’px; height:’+(barheight-2)+’px; background-color:’+unloadedcolor+’; font-size:1px;”></div>’;
txt+='<div id=”perdone” style=”position:absolute; top:1px; left:1px; width:0px; height:’+(barheight-2)+’px; background-color:’+loadedcolor+’; font-size:1px;”></div>’;
txt+='<div style=”position:absolute; top:2px; left:1px; width:’+(barwidth-2)+’px; height:’+(barheight-2)+’px; color:’+textColor+’; font-size:’+textSize+’; font-family:’+textFont+’; text-align:center; cursor:default”>LOADING…</div>’;
txt+='</div>’;
}
document.write(txt);

//THIS FUNCTION BY MIKE HALL OF BRAINJAR.COM
function findlayer(name,doc){
var i,layer;
for(i=0;i<doc.layers.length;i++){
layer=doc.layers[i];
if(layer.name==name)return layer;
if(layer.document.layers.length>0)
if((layer=findlayer(name,layer.document))!=null)
return layer;
}
return null;
}

function loadimages(){
perouter=(NS4)?findlayer(‘perouter’,document):(IE4)?document.all[‘perouter’]:document.getElementById(‘perouter’);
perdone=(NS4)?perouter.document.layers[‘perdone’]:(IE4)?document.all[‘perdone’]:document.getElementById(‘perdone’);
if(NS4)perouter.captureEvents(Event.MOUSEUP);
perouter.onmouseup=hidebar;
clipEl(perdone,0,0,barheight-2,0);
if(NS4)perouter.visibility=”show”;
else perouter.style.visibility=”visible”;
for(n=0;n<imagenames.length;n++){
images[n]=new Image();
images[n].src=imagenames[n];
if(images[n].complete)dispbars();
images[n].onload=dispbars;
images[n].onerror=dispbars;
}}

function dispbars(){
loaded++;
clipEl(perdone, 0, blocksize*loaded, barheight-2, 0);
if(loaded>=imagenames.length)setTimeout(‘action()’, 800);
}

function hidebar(){
if(NS4)perouter.visibility=”hide”;
else perouter.style.visibility=”hidden”;
}

function clipEl(el, ct, cr, cb, cl){
if(NS4){
el.clip.left=cl;
el.clip.top=ct;
el.clip.right=cr;
el.clip.bottom=cb;
}else el.style.width=cr+’px’;
}

function get_cookie(Name) {
var search=Name+”=”;
var returnvalue=””;
if(document.cookie.length>0){
offset=document.cookie.indexOf(search);
if(offset!=-1){
offset+=search.length;
end=document.cookie.indexOf(“;”,offset);
if(end==-1)end=document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset,end));
}}
return returnvalue;
}

window.onload=function(){
var okPB=false;
if (loadonce){
if(get_cookie(“progB”)==””){
okPB=true;
document.cookie=”progB=yes”;
}}
else okPB=true;
if(okPB)setTimeout(‘loadimages()’,300);
}

–>
[/code]

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@Khalid_AliSep 03.2003 — yes you should be able to do that depending upon what exactly you are looking to do.A wrong insert of the code might break the whole script.
Copy linkTweet thisAlerts:
@JonathanauthorSep 04.2003 — Can I turn

image = new Image()

image.src = "something.gif"

into

function preload()

image = new Image()

image.src = "something.gif"

Let me know how...
Copy linkTweet thisAlerts:
@Khalid_AliSep 04.2003 — almost as you did here is the correct syntax

function preload(){

image = new Image()

image.src = "something.gif"

}

and then you will need to call this function in the onload like this

<body onload="preload()">
Copy linkTweet thisAlerts:
@JonathanauthorSep 04.2003 — oh yeah ? I was thinking a diff. lang. ?
Copy linkTweet thisAlerts:
@Khalid_AliSep 04.2003 — you are welcome???
Copy linkTweet thisAlerts:
@JonathanauthorSep 04.2003 — Yeah thanks!
×

Success!

Help @Jonathan spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...