Scrolling Cart Script for a particular catalog item

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2016 11:57 AM
Hi am trying this script for my catalog item that I got from the user community and I keep getting an error. Can someone take a look please?
Here is the link where I got the code from: Scrolling Cart for Service Request - Oslova Networks
Thank you,
Karen

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2016 07:03 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2016 07:10 AM
var adder;
var adderFound = 'false';
var cartContent;
var cartContentFound = 'false';
function onLoad()
{
adder = gel('adder');
if (adder)
{
adder.style.position = "relative";
adderFound = 'true';
}
cartContent = gel('sc_cart_contents');
if (cartContent)
{
cartContent.style.position = "relative";
cartContentFound = 'true';
}
window.onscroll = function()
{
var y = 12;
if (typeof window.pageYOffset != 'undefined')
y = window.pageYOffset;
else if (typeof document.documentElement.scrollTop != 'undefined' && document.documentElement.scrollTop > 0)
y = document.documentElement.scrollTop;
else if (typeof document.body.scrollTop != 'undefined')
y = document.body.scrollTop;
if (y > 60)
{
if (adderFound == 'true')
adder.style.top = y - 60 + 'px';
if (cartContentFound == 'true')
cartContent.style.top = y - 60 + 'px';
}
else
{
if (adderFound == 'true')
adder.style.top = 0 + 'px';
if (cartContentFound == 'true')
cartContent.style.top = 0 + 'px';
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2016 07:22 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2016 07:25 AM
Re-examining my code, you may wish to make:
var adder;
var adderFound = 'false';
var cartContent;
var cartContentFound = 'false';
function onLoad()
{
adder = gel('adder');
Into:
var adder;
var cartContent;
function onLoad()
{
var adderFound = 'false';
var cartContentFound = 'false';
adder = gel('adder');

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2016 08:13 AM
Now, to address the "already defined" issue in the catch statements, you can use the first piece of code I gave you and change all your catch(e) lines to catch(e1), catch(e2), catch(e3), etc... giving each catch parameter it's own namespace. This is a known issue with JavaScript's try/catch, as noted here: http://stackoverflow.com/questions/6100230/javascript-catch-parameter-already-defined