198 posts
  • Has been part of the Envato Community for over 5 years
  • Has collected 500+ items on Envato Market
  • Located in United States
I’m working with a multiple div ID parallax 3D effect. I tried it with this code once and it worked great, but now it’s giving me this error in the console ->
Uncaught TypeError: Cannot read property 'style' of null parallax.js:87
220Uncaught TypeError: Cannot read property 'style' of null parallax.js:79
Uncaught TypeError: Cannot read property 'style' of null parallax.js:79
moveDiv parallax.js:79
getMouseXY parallax.js:69
229Uncaught TypeError: Cannot read property 'style' of null parallax.js:79
Uncaught TypeError: Cannot read property 'style' of null parallax.js:79
moveDiv parallax.js:79

Here is my parallax.js code

var verticalPosition;
var verticalPositionBefore;
var windowWidth = 960;
var windowHeight;

// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var tempX = 0;
var tempY = 0;

var objectArray = new Array();


function fillObjectArray()
var ssplashesDiv = document.getElementById("ssplashes");
var ssplashesX = 312;
var ssplashesY = 33;
var ssplashesFactor = 0.05;
var ssplashesArray = new Array();

var msplashesDiv = document.getElementById("msplashes");
var msplashesX = 312;
var msplashesY = 33;
var msplashesFactor = 0.05;
var msplashesArray = new Array();

var bsplashesDiv = document.getElementById("bsplashes");
var bsplashesX = 312;
var bsplashesY = 33;
var bsplashesFactor = 0.05;
var bsplashesArray = new Array();


// Main function to retrieve mouse x-y pos.s

function getMouseXY(e)
      if (IE) { // grab the x-y pos.s if browser is IE
        tempX = event.clientX + document.body.scrollLeft
        tempY = event.clientY + document.body.scrollTop
      } else {  // grab the x-y pos.s if browser is NS
        tempX = e.pageX
        tempY = e.pageY
      // catch possible negative values in NS4
      if (tempX < 0){tempX = 0}
      if (tempY < 0){tempY = 0}  


      return true

function moveDiv(tempX)
    for (var i=0;i<objectArray.length;i++)
        var yourDivPositionX = objectArray[i][3] * (0.5 * windowWidth - tempX) + objectArray[i][1];
        objectArray[i][0].style.left = yourDivPositionX + 'px';

function positionDivs()
    for (var i=0;i<objectArray.length;i++)
        objectArray[i][0].style.left = objectArray[i][1] + "px";
        objectArray[i][0].style.top = objectArray[i][2] + "px";

The site is on my localhost so unfortunately I can’t provide a link.


502 posts
  • Has referred 10+ members
  • Has sold $40,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more

you can’t get the object before you can get the style. I guess you store the options for each section in style of container. try to get container again!

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes