Solved

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

Posted on 2008-10-21
2
734 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

One of the biggest threats facing all high-value targets are APT's.  These threats include sophisticated tactics that "often starts with mapping human organization and collecting intelligence on employees, who are nowadays a weaker link than network…
For months I had no idea how to 'discover' the IP address of the other end of a link (without asking someone who knows), and it drove me batty. Think about it. You can't use Cisco Discovery Protocol (CDP) because it's not implemented on the ASAs.…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

815 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

11 Experts available now in Live!

Get 1:1 Help Now