/    Sign up×
Community /Pin to ProfileBookmark

Error: 1.offsetWidth is null or not an object

Hello.

I have a Javascript ticker, which scrolls horizontally across the screen. The Javascript creates the marquee where the text scrolls as well as actually jumping the text across the page. In addition, there are checks and different functions depending on what browser is being used.

Alone in a .aspx file this ticker works exactly as it should. But when I put it into a .aspx file with other content, both HTML and .NET it gives a

Error: 1.offsetWidth is null or not an object

This error refers to the block of code:
ns6divw = eval(whichdiv);
ns6divw.style.left = newsWidth;
ns6divw.innerHTML = ‘<nobr>’+’Some message’+'</nobr>’;
var nobrnode = ns6divw.getElementsByTagName(‘span’);
sizeupw = nobrnode[1].offsetWidth;
sizeupw = ns6divw.offsetWidth;

And the line where the error occurs is at sizeupw = nobrnode[1].offsetWidth;

I’m confused because in the separate file, this object isn’t null but once I implement it in my .aspx content page, it is.

Is there something I’m missing? Does anyone have any ideas?

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @Lauren_S 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 5.16,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...