Solved

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

Posted on 2008-10-21
2
732 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
ID: 22773996
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
ID: 22774779
You were right, thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Node.js 6 204
Help with NVD3 graphs - adding 'markers' 17 708
Problem to the codes 19 99
Problem to the codes 3 85
We need a new way to communicate time sensitive or critical info.   The best part of my role at xMatters is visiting our clients all over the world to learn about how they operate their businesses, share insights that xMatters has gleaned across…
In 2017, ransomware will become so virulent and widespread that if you aren’t a victim yourself, you will know someone who is.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

910 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

16 Experts available now in Live!

Get 1:1 Help Now