Solved

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

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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 inconsistent results 10 164
Modifying My Json Race Series Page 2 123
Expand and Collapse Tree Grid 11 574
Display value of dropdown list using javascript. 16 70
In case you ever have to remove a faulty web part from a page , add the following to the end of the page url ?contents=1
This article shows the method of using the Resultant Set of Policy Tool to locate Group Policy that applies a particular setting.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

821 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