Log In · Register

 
 
Closed TopicStart new topic
custom scrollbar, for my boxed xanga
sikdragon
post Aug 9 2004, 02:29 AM
Post #1


Bardic Nation
******

Group: Member
Posts: 1,113
Joined: Aug 2004
Member No: 38,059



Ok i tried to put a custom scroll on my boxed xanga which is a div and lets say the div's id is xanga226892, what the hell did i do wrong? this thing took me forever. this code was all in the custom header. the pic links are bad i know but it shouldnt effect the whole thing. when i hover over the buttons it says "object expected".
CODE
<!-- begin code provided by createblog.com -->



<script type="javascript">
var scrollPeriod = 100;
var scrolling = false;

function getStyleById(id, property) {
 var element = document.getElementById(id);
 var style =;

 if ((style != "") && (style != null)) {
   return style;
 }

 if (element.currentStyle) {
   style =;
   if ((style != "") && (style != null)) {
     return style;
   }
 }

 return null;
}

function setStyleById(id, property, value) {
 var element = document.getElementById(id);
 element.style[property] = value;
}

// FIXME: this should be moved to a utility library
function getElementHeight(element) {
 var height = null;
 if (document.defaultView && document.defaultView.getComputedStyle) {
   var computedStyle = document.defaultView.getComputedStyle(element, "");
   height = computedStyle.getPropertyValue("height");
 }
 if ((height == null) || (height.length < 1)) {
   height = element.offsetHeight;
 }
 return parseInt(height);
}

function scroll(containerId, contentId, direction, amount) {
 var containerDiv = document.getElementById(containerId);
 var contentDiv = document.getElementById(contentId);
 var topOffset = parseInt(getStyleById(contentId, 'top'));
 if (isNaN(topOffset)) {
   topOffset = 0;
 }
 var containerHeight = getElementHeight(containerDiv);  
 var contentHeight = getElementHeight(contentDiv);
 var newOffset;
 if (direction == 'top') {
   newOffset = 0;
 }
 else if (direction == 'bottom') {
   newOffset = containerHeight - contentHeight;
 }
 else if (direction == 'up') {
   newOffset = topOffset + amount;
 }
 else if (direction == 'down') {
   newOffset = topOffset - amount;
 }
 else if (direction == 'to') {
   newOffset = 0 - amount;
 }
 if (newOffset > 0) {
   newOffset = 0;
 }
 if ((containerHeight - newOffset) > contentHeight) {
   newOffset = containerHeight - contentHeight;
 }

 contentDiv.style['top'] = newOffset;

 return true;
}

function scrollUp(containerId, contentId) {
 return scroll(containerId, contentId, 'up');
}
function scrollDown(containerId, contentId) {
 return scroll(containerId, contentId, 'down');
}
function scrollToTop(containerId, contentId) {
 return scroll(containerId, contentId, 'top');
}
function scrollToBottom(containerId, contentId) {
 return scroll(containerId, contentId, 'bottom');
}

function scrollContinuous(containerId, contentId, direction, amount) {
 if (scrolling) {
   scroll(containerId, contentId, direction, amount);
   window.setTimeout("scrollContinuous('" + containerId + "', '" + contentId
                     + "', '" + direction + "', " + amount + ");", scrollPeriod);
 }
}

function scrollStart(containerId, contentId, direction, amount) {
 scrolling = true;
 scrollContinuous(containerId, contentId, direction, amount);
}

function scrollStop() {
 scrolling = false;
}

function scrollSetup(containerId, contentId, controlsId) {
 var container = document.getElementById(containerId);
 var content = document.getElementById(contentId);
 var controls = document.getElementById(controlsId);
 var containerHeight = getElementHeight(container);  
 var contentHeight = getElementHeight(content);

 if (contentHeight <= containerHeight) {
   controls.style['visibility'] = 'hidden';
 }
}
</script>


<script language="javascript">
function onBodyLoad() {
self.focus();
scrollSetup('xanga226892', 'none');
scrollSetup('xanga226892', 'none');
}
</script>


<div id="none" style="position:absolute;">
<a href="#" onmouseover="scrollStart('xanga226892', 'up', 10); return false;" onmouseout="scrollStop(); return false;"><img src="/sitewide/assets/img/buttons/up.gif" onclick="return false;" alt="" border="0"></a> <a href="#" onmouseover="scrollStart('xanga226892', 'down', 10); return false;" onmouseout="scrollStop(); return false;" onmouseout="scrollStop();" onclick="return false;"><img src="/sitewide/assets/img/buttons/down.gif" alt="" border="0"></a>
</div>


<!-- end code provided by createblog.com -->
 
cyphervi
post Aug 9 2004, 09:42 AM
Post #2


local html help
****

Group: Member
Posts: 146
Joined: Mar 2004
Member No: 9,395



there should be a yellow script error icon in the status bar. double click it and find out which lines you have errors on.
 
sikdragon
post Aug 10 2004, 04:23 AM
Post #3


Bardic Nation
******

Group: Member
Posts: 1,113
Joined: Aug 2004
Member No: 38,059



nope it doesnt have a yellow box but according to the error message there is a problem with the links inside of the "none" div.
 
DrNick311
post Aug 10 2004, 08:26 AM
Post #4


.
******

Group: Member
Posts: 1,488
Joined: Feb 2004
Member No: 3,625



Does that script work for DIVs? I've seen some scripts that do the same thing, but they only work on iFrames, which Xanga doesn't support.
 
sikdragon
post Aug 10 2004, 02:15 PM
Post #5


Bardic Nation
******

Group: Member
Posts: 1,113
Joined: Aug 2004
Member No: 38,059



yeah it works on divs i saw it
 

Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members: