/    Sign up×
Community /Pin to ProfileBookmark

newbie help… moving text across screen

I have some text that is starting at 0,0 on my page and I want it to scroll to the center and once there, call a new function.

When I load the page (moveBook()), my text doesn’t move. The code follows….

var W = (winWidth()/2)

function moveBook() {
var x = xCoord(“Books”);
if (x <= W-125) {
shiftIt(“Books”,10,0);
setTimeout(“moveBook()”,50);
} else {
swapImages();
}
}

function xCoord(id) {
var object=getObject(id);
if (NS4DOM) xc=object.left;
else if (IEDOM) xc=object.style.pixelLeft;
else if (W3CDOM) xc=parseInt(object.style.left);
return xc;
}

function winWidth() {
if (window.innerWidth) return window.innerWidth;
else if (document.documentElement) return document.documentElement.offsetWidth;
else if (document.body.clientWidth) return document.body.clientWidth;
}

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@96turnerriFeb 18.2004 — how exactly are you calling this function? <body onload="moveBook();"> ??
Copy linkTweet thisAlerts:
@btsixerauthorFeb 18.2004 — Yes... <body onload="moveBook()">

Further, to debug, can I <body onload="alert("HI")"> to check and make sure that is working? Because when I do, that doesn't work either..
Copy linkTweet thisAlerts:
@PittimannFeb 18.2004 — Hi!Further, to debug, can I <body onload="alert("HI")"> to check and make sure that is working? Because when I do, that doesn't work either[/QUOTE]That cannot work. For that, you should use:

<body onload="alert('HI')">

Cheers - Pit
×

Success!

Help @btsixer 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.4,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...