Log In · Register

 
Custom Scrollbar
sikdragon
post Aug 9 2004, 05:39 AM
Post #1


Bardic Nation
******

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



I seem to have stumped all the xanga help people that are on at 5:30 once again in my 3 days.

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". As far as i can tell all the objects are in place.
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 -->
 
 
Start new topic
Replies
sikdragon
post Aug 9 2004, 08:12 PM
Post #2


Bardic Nation
******

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



no its the next line down, it is having a problem with the link tags.
this is programming chat, its supposed to be more advanced than xanga help. Come on guys where are you?
 

Posts in this topic


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