Solved

IE 7 throws "invalid argument" jscript error when change "top" css property

Posted on 2008-10-21
2
731 Views
Last Modified: 2012-05-05
Trying to change the top position of an element... if I pass in the value as a variable like this:
parent.document.getElementById(id).style.top  = newLocation + "px";
I get an "invalid argument" error in javascript.

However, if I manually put in a value like this:
parent.document.getElementById(id).style.top  = "200px";
It passes.

Full code of my function below.
function nudge(id,top,left) {

	

	if(top != "") {

		curLocation = parseInt(parent.document.getElementById(id).style.top);

		newLocation = parseInt(curLocation) + parseInt(top);

		parent.document.getElementById(id).style.top  = newLocation + "px";

	}

	

	if(left != "") {

		curLocation = parseInt(parent.document.getElementById(id).style.left);

		newLocation = parseInt(curLocation) + parseInt(left);

		parent.document.getElementById(id).style.left  = newLocation + "px";

	}

}

Open in new window

0
Comment
Question by:susanBuck
2 Comments
 
LVL 5

Accepted Solution

by:
jose_juan earned 250 total points
Comment Utility
Hi susanBuck,

probably your newLocation not is a valid number, to debug it show the newLocation (e.g. document.title = newLocation). Probably you have a NaN value.

Regards.
0
 

Author Comment

by:susanBuck
Comment Utility
You were right, thanks!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
In this article, you will read about the trends across the human resources departments for the upcoming year. Some of them include improving employee experience, adopting new technologies, using HR software to its full extent, and integrating artifi…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now