473,324 Members | 2,196 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Problem with Opera an IE

Si
Hi,

I'll start by saying I'm a complete newbie, this is the first time I
have used Javascript.

The code below I have written to calculate distance/bearings and times
from a grid reference.

It works absolutely fine in Opera 7.11, but in IE it throws up an
"object doesn't support this operation or method" error.

Any help/suggestions to where I have gone wrong and how I can get this
working in IE would be greatly appreciated.

Cheers Si,

###############CODE###################

function distance(form) {
var x1 = eval(form.x1.value);
var y1 = eval(form.y1.value);
var x2 = eval(form.x2.value);
var y2 = eval(form.y2.value);
var sd = eval(form.s.value);
var xdiff = x2 - x1;
var ydiff = y2 - y1;
var y = Math.pow((xdiff * xdiff + ydiff * ydiff), 0.5)/10;
if (Math.atan2((y2 - y1),-(x2 - x1)) * (180 / Math.PI) - 90 < 0) {
var b = Math.atan2((y2 - y1),-(x2 - x1)) * (180 / Math.PI) + 270;
}
else {
var b = Math.atan2((y2 - y1),-(x2 - x1)) * (180 / Math.PI) - 90;
}
var t = y / sd;
form.distance.value = Math.round(10*y)/10
form.time.value = (Math.round(10*t)/10)*60
form.bear.value = Math.round(b)
}
###########################################
Jul 20 '05 #1
3 2325
s.***@cwcom.net (Si) writes:
The code below I have written to calculate distance/bearings and times
from a grid reference.

It works absolutely fine in Opera 7.11, but in IE it throws up an
"object doesn't support this operation or method" error.
It would be very helpful to know which line the error comes from,
what the form contains and how the function is called.


function distance(form) {
var x1 = eval(form.x1.value);
The "eval" function is a very slow way to turn a string into a number
(by a factor of 80 in some browsers). The fastest way us to use a
unary prefix plus. I.e.,

var x1 = +(form.x1.value);

You will probably never need to use "eval" for anything. There are
better and faster ways of solving most problems that a normal page
author runs into. Don't trust solutions that use "eval".
form.distance.value = Math.round(10*y)/10


You have an input element with the name "distance". IE makes a global
variable with that name that refers to the input element. However,
that overwrites your function called "distance". Change the name
of either the input element or the function.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
Si
Lasse,

I Changed both things you suggested and it works great now.

Many Thanks.

Si,

Lasse Reichstein Nielsen <lr*@hotpop.com> wrote in message news:<r8**********@hotpop.com>...
s.***@cwcom.net (Si) writes:
The code below I have written to calculate distance/bearings and times
from a grid reference.

It works absolutely fine in Opera 7.11, but in IE it throws up an
"object doesn't support this operation or method" error.


It would be very helpful to know which line the error comes from,
what the form contains and how the function is called.


function distance(form) {
var x1 = eval(form.x1.value);


The "eval" function is a very slow way to turn a string into a number
(by a factor of 80 in some browsers). The fastest way us to use a
unary prefix plus. I.e.,

var x1 = +(form.x1.value);

You will probably never need to use "eval" for anything. There are
better and faster ways of solving most problems that a normal page
author runs into. Don't trust solutions that use "eval".
form.distance.value = Math.round(10*y)/10


You have an input element with the name "distance". IE makes a global
variable with that name that refers to the input element. However,
that overwrites your function called "distance". Change the name
of either the input element or the function.

/L

Jul 20 '05 #3
JRS: In article <a7**************************@posting.google.com >, seen
in news:comp.lang.javascript, Si <s.***@cwcom.net> posted at Fri, 31 Oct
2003 15:46:09 :-

if (Math.atan2((y2 - y1),-(x2 - x1)) * (180 / Math.PI) - 90 < 0) {
var b = Math.atan2((y2 - y1),-(x2 - x1)) * (180 / Math.PI) + 270;
}
else {
var b = Math.atan2((y2 - y1),-(x2 - x1)) * (180 / Math.PI) - 90;
}

If that's to convert (X, Y) to bearing from North, there must be an
easier way. Try exchanging X & Y, to get +-180 deg from North.

B = Math.atan2(X, Y)*180/Math.PI // -180<B<=+180
B = (360+Math.atan2(X, Y)*180/Math.PI)%360 // 0<=B<360

Unless the span is certainly small, you should warn about approximations
die to the Non-Flat Earth.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Marcus Bjorke | last post by:
I use a print link that causes a problem with Opera 7. The link looks like this <a href="javascript:parent.frames.mainFrame.print()">Print this page</a> I also used <a...
6
by: Shaun Fleming | last post by:
I've been trying to make this simple script compatible across various browsers. It works for IE 6.0 and NS 7 but doesnt work with Opera (I have version 7.11). This is what is supposed to happen:...
28
by: Lachlan Hunt | last post by:
Hi, I've been trying, but failing to work out what is causing Opera to render my drop down menu incorrectly on my site. http://www.lachy.id.au/ For some reason, there seems to be extra margin...
18
by: David Morris | last post by:
G'day. Is there a known "display:block;" problem in opera? In playing around trying to get some cross browser conformance, I either inadvertently or redundantly (depending on your perspective)...
14
by: Philip Herlihy | last post by:
I've been trying to create a simple vertical navigation bar, using (as recommended) an unordered list (UL) of hyperlinks. I'd like to have a hover effect, so I have to style the links themselves....
5
by: Chris Beall | last post by:
See http://pages.prodigy.net/chris_beall/BeallSprings/WC.Deed%20GG.116-17.html using the CSS at http://pages.prodigy.net/chris_beall/BeallSprings/BSstyle.css The page is a transcript of a...
5
by: Paul Fi | last post by:
Can someone help me here because this is really killing me! the problem is, i have this javascript code in my aspx page that i want it to work on almost all browsers, especially opera and safari...
4
by: VR | last post by:
First, greetings to everyone :) I'm doing a university seminar & I've encountered a problem. I have a gallery with thumbnails linked on pictures. What I want is popup to be opened with...
34
by: Simon Wigzell | last post by:
document...focus() will scroll the form to move the specified text field into view on everything I have tried it with except Safari on the MAC. The form doesn't move. Any work around? Thanks.
102
by: hug | last post by:
www.webmaster, was suggested that this ng could be a better place.] I've updated my test server to handle if-modified-since. I've noticed that the (old copies I run of) IE and Netscape seem...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.