/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Help revising code for a floating layer

About 5 years ago, I uploaded this code for a floating layer on my website – works really really well, the only problem is – I forgot what the code means (I’m not a javascript expert)! The floating layer is positioned in the center of the screen and I now want to move it to the far left of the screen. How do I adjust the code to do that?? Sorry for the dumb question, but it’s been years… Can someone highlight the section of the code related to the screen position, and tell me how to adjust the position???

var useFloat = “”;
var nV = 0;
var tick = “”;

function hideMessage(){

clearTimeout(tick);
useFloat.style.display = ‘none’;
}

function stayHome(){

var xV = 0;
if(!document.body.scrollTop){xV = document.documentElement.scrollTop}
else {xV = document.body.scrollTop}
useFloat.style.top = nV+xV+”px”
tick = setTimeout(“stayHome()”,50);
}

function showMessage(nText){

useFloat.style.display = “”;
useFloat.innerHTML = nText;
stayHome();
}

function init(){

useFloat = document.getElementById(‘isFloat’);
nV = useFloat.offsetTop;
useFloat.style.display = ‘none’;
var msgWidth = parseInt(useFloat.style.width)
useFloat.style.left = ((screen.width-30)/2)-(msgWidth/2)+”px”;
}

window.onload=init;

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf(“?”))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_setTextOfLayer(objName,x,newText) { //v4.01
if ((obj=MM_findObj(objName))!=null) with (obj)
if (document.layers) {document.write(unescape(newText)); document.close();}
else innerHTML = unescape(newText);
}

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FangFeb 01.2010 — useFloat.style.left = "0px";
Copy linkTweet thisAlerts:
@Bel_EspritauthorFeb 02.2010 — Thanks soooo much! I knew that was the line I had to change, but couldn't make head or tail out of what was there. Of course, now that I see how stupidly simple it was, I do believe your quote applies to me - banana anyone?
×

Success!

Help @Bel_Esprit 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 6.13,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

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