/    Sign up×
Community /Pin to ProfileBookmark

Javascript tweaking

I found this code that my friend gave me. It’s suppost to create a floating image for your website, and when I say floating I mean it stays on the bottom of the browser’s window even if they scroll. My problem is, i want to make the current image to the file: [url]http://kevinreturns.webs.com/Shell/Root/op/Shell/IMAGES/Comment.png[/url]
And the link to:
[url]http://kevinreturns.webs.com/apps/guestbook[/url]

If you could teach me how to do this, i would appreciate it!

[code=php] window[“_load_random_xmd0kf4ghe846jqo9pd”] = function() {
var f = _fw.freebar;
if (!f) return;

_fw.bgcolor = document.bgColor;
var str = ”;
var o,opacity,top;
var h = 1;
if (_fw.adv) {
_fw.adv.style.backgroundColor = ‘transparent’;
var rows = _fw.gradheight = 120;
var fullheight = _fw.fullheight = 140;
}
else {
var rows = _fw.gradheight = 40;
var fullheight = _fw.fullheight = 60;
}

for (var i=0;i<rows;i++) {
top = i*h;
o = i*(100/rows);
opacity = (document.all)? opacity = ‘filter:alpha(opacity=’+o+’);’ : ‘opacity:’+(o/100)+’;’;
str += ‘<div style=”position:absolute; overflow:hidden; width:100%; height:’+h+’px; left:0px; top:’+top+’px; background-color:#ffffff; ‘+opacity+'”></div>n’; // ;
}
str += ‘<div id=”fw_content” style=”position:absolute; overflow:hidden; width:100%; height:’+(fullheight-(h*rows))+’px; left:0px; top:’+(h*rows)+’px; background:#367cbf url(”+_fw.imagesprefix+’bar_fadewhite-bg.gif’) repeat-x top;”></div>’;
str += ‘<div style=”position:absolute; width:100%; left:0px; top:’+(fullheight-33)+’px; text-align:center; z-index:1000″><a href=”‘+_fw.url+'” target=”_top”><img src=”‘+_fw.imagesprefix+’bar_fadewhite.gif” width=439 height=33 border=0></a></div>’;
f.innerHTML = str;
f.style.width = ‘100%’;
f.style.height = fullheight+’px’;
}
window[“_set_random_xmd0kf4ghe846jqo9pd”] = function() {
var f = _fw.freebar;
if (f && document.all) f.style.width = document.body.clientWidth + document.body.scrollLeft+’px’;
var dh = document.body.scrollHeight;
var wh;
if (document.all) {
wh = document.documentElement.clientHeight;
if (wh==0) wh = document.body.clientHeight;
}
else {
if (dh<window.innerHeight) wh = window.innerHeight;
else wh = document.body.clientHeight;
}
var st = (_fw.cssfixed)? 0:parseInt(document.body.scrollTop);

var y = st + wh – _fw.fullheight;
var h = dh – y;

if (h<_fw.fullheight) h = _fw.fullheight;

if (f) {
f.style.top = y+’px’;
f.style.height = h+’px’;
var ch = h-(_fw.fullheight-_fw.gradheight);
if (ch<(_fw.fullheight-_fw.gradheight)) ch = _fw.fullheight-_fw.gradheight;
_fw.contentbar.style.height = ch;
}
if (_fw.adv) {
_fw.adv.style.top = (y+10)+’px’;
}
} [/code]

:rolleyes: I am new with Javascript bt the way.

to post a comment
JavaScript

18 Comments(s)

Copy linkTweet thisAlerts:
@Kevin_s_DogauthorNov 24.2009 — Guys, I'm sorry i may of made some typing mistakes, it happens alot with me ?
Copy linkTweet thisAlerts:
@criterion9Nov 24.2009 — You mean like this?
[code=html]
<a href="your_link_here"><img src="your_image_source" border="0" /></a>
[/code]
Copy linkTweet thisAlerts:
@Kevin_s_DogauthorNov 25.2009 — You mean like this?
[code=html]
<a href="your_link_here"><img src="your_image_source" border="0" /></a>
[/code]
[/QUOTE]


Yes.

But, with this javascript code, It "Locks" the image to the bottom of the web-browser. So if you scroll, it stays at the bottom of the viewer's page. Its only for my comments page. ?
Copy linkTweet thisAlerts:
@Kevin_s_DogauthorNov 25.2009 — Here is an example of what I mean by how it "Locks", Its the original code for it:

http://members.webs.com/MembersA/freebarSample.jsp?freebar=bar_fadewhite
Copy linkTweet thisAlerts:
@criterion9Nov 25.2009 — This code is just spitting out html anyway:

str += '<div id="fw_content" style="position:absolute; overflow:hidden; width:100%; height:'+(fullheight-(h*rows))+'px; left:0px; top:'+(h*rows)+'px; background:#367cbf url(''+_fw.imagesprefix+'bar_fadewhite-bg.gif') repeat-x top;"></div>';

str += '<div style="position:absolute; width:100%; left:0px; top:'+(fullheight-33)+'px; text-align:center; z-index:1000"><a href="'+_
fw.url+'" target="_top"><img src="'+_fw.imagesprefix+'bar_fadewhite.gif" width=439 height=33 border=0></a></div>';
[/quote]


Just change to meet your needs.
Copy linkTweet thisAlerts:
@Kevin_s_DogauthorNov 25.2009 — This code is just spitting out html anyway:


Just change to meet your needs.[/QUOTE]


Thank you ?
Copy linkTweet thisAlerts:
@Kevin_s_DogauthorNov 25.2009 — Will this work?

[code=php]

str += '<div id="fw_content" style="position:absolute; overflow:hidden; width:100&#37;; height:'+(fullheight-(h*rows))+'px; left:0px; top:'+(h*rows)+'px; background:#367cbf url(/'http://kevinreturns.webs.com/Shell/Root/op/Shell/IMAGES/Comment.png') repeat-x top;"></div>';
str += '<div style="position:absolute; width:100%; left:0px; top:'+(fullheight-33)+'px; text-align:center; z-index:1000"><a href="'+_fw.url+'" target="_top"><img src="http://kevinreturns.webs.com/Shell/Root/op/Shell/IMAGES/Comment.png" width=439 height=33 border=0></a></div>';

[/code]
Copy linkTweet thisAlerts:
@criterion9Nov 25.2009 — Did you try it?

Did it work?
Copy linkTweet thisAlerts:
@Kevin_s_DogauthorNov 25.2009 — I use SciTE to debug all of my coding, it gave me this error:

C:Documents and SettingsStudentMy Documentsbar_fadewhite.js(25, 177) Microsoft JScript compilation error: Expected ';'


Its at line 25:

str += '<div id="fw_content" style="position:absolute; overflow:hidden; width:100&#37;; height:'+(fullheight-(h*rows))+'px; left:0px; top:'+(h*rows)+'px; background:#367cbf url(/'http://kevinreturns.webs.com/Shell/Root/op/Shell/IMAGES/Comment.png') repeat-x top;"></div>';

At character 177, which I dont know where character 177 is
Copy linkTweet thisAlerts:
@criterion9Nov 25.2009 — 
'http://kevinreturns.webs.com/Shell/Root/op/Shell/IMAGES/Comment.png'
[/quote]

<i>
</i>"http://kevinreturns.webs.com/Shell/Root/op/Shell/IMAGES/Comment.png"

Your variable is using single quotes (') to enclose the string. You need to either escape the quotes (') or use double quotes (") as the rest of the variable declaration does.
Copy linkTweet thisAlerts:
@Kevin_s_DogauthorNov 25.2009 — Its telling me there is an error on the page,

My file directory is here:


[CODE]
<!-- loliville -->
<script language="JavaScript" src="http://kevinreturns.webs.com/Shell/Root/op/Shell/Javascripts/bar_fadewhite.js">
</script>[/CODE]
Copy linkTweet thisAlerts:
@criterion9Nov 25.2009 — What is on line 25 now? There is little need to go through the whole file if you just changed that one line.
Copy linkTweet thisAlerts:
@Kevin_s_DogauthorNov 25.2009 — What is on line 25 now? There is little need to go through the whole file if you just changed that one line.[/QUOTE]
[code=php] str += '<div id="fw_content" style="position:absolute; overflow:hidden; width:100&#37;; height:'+(fullheight-(h*rows))+'px; left:0px; top:'+(h*rows)+'px; background:#367cbf url("http://kevinreturns.webs.com/Shell/Root/op/Shell/IMAGES/Comment.png") repeat-x top;"></div>';
[/code]


I don't know where to put the link part at :l
Copy linkTweet thisAlerts:
@criterion9Nov 25.2009 — This part already had your image and link in it. What does _fw.url contain?



str += '<div style="position:absolute; width:100&#37;; left:0px; top:'+(fullheight-33)+'px; text-align:center; z-index:1000"><a href="'+_fw.url+'" target="_top"><img src="http://kevinreturns.webs.com/Shell/Root/op/Shell/IMAGES/Comment.png" width=439 height=33 border=0></a></div>';

[/quote]
Copy linkTweet thisAlerts:
@Kevin_s_DogauthorNov 25.2009 — [code=php]window["_load_random_xmd0kf4ghe846jqo9pd"] = function() {
var f = _fw.freebar;
if (!f) return;[/code]



Thats all I got from the code ._.

The original can be found here: http://images.freewebs.com/JS/Freebar/bar_stretchblack.js
Copy linkTweet thisAlerts:
@criterion9Nov 25.2009 — _fw is being set somewhere else besides the code you posted. You can either find where _fw.url is being set or you can just remove the '_fw.url' and replace with your link.
Copy linkTweet thisAlerts:
@Kevin_s_DogauthorNov 25.2009 — I've noticed that the variable "f" Is being used for somthing.

E.X.:

f.innerHTML = str;

f.style.width = '100%';

f.style.height = fullheight+'px'

I'm not sure about this code, I found it, and I'm stumped.

Really, all I want is a locked image with link combo.
Copy linkTweet thisAlerts:
@criterion9Nov 26.2009 — Are you including another javascript? It seems to me that you must be or there must be some other code embeded in your page for _fw to have been set. Those three lines are setting things and placing the html string on what I'm assuming is a div element referenced by "_fw.freebar" towards the top of your function.
×

Success!

Help @Kevin_s_Dog 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.18,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

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