Solved

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

Posted on 2008-10-21
2
736 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
I need jquery to load a url in an iframe on another page 12 326
Trying to format phone number on keyin. 5 100
Dropdownlist not working properly 6 87
Jquery validation not working. 29 224
A hard and fast method for reducing Active Directory Administrators members.
CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
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…

734 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