Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #16690

Re: function argument type

From Denis McMahon <denismfmcmahon@gmail.com>
Newsgroups comp.lang.javascript
Subject Re: function argument type
Date 2012-10-17 17:39 +0000
Organization A noiseless patient Spider
Message-ID <k5mqgd$nnp$1@dont-email.me> (permalink)
References <352fc896-b38a-401b-bdc9-9a342d52a8ed@googlegroups.com>

Show all headers | View raw


On Wed, 17 Oct 2012 09:12:07 -0700, Michele Da Ros wrote:

> hi to all I'm trying to call an applet method from a js script
> 
> this is the code
> 
> function jump() {
>   var x = 1374795;
>   var y = 5700582;
>   var z = 170; document.xnavigator.jumpToCoordinate(x,y,z);
> }
> 
> the problem is that it works only on some browsers (firefox on Linux)
> In other browsers the applet throws an illegalarguments exception, but
> this version works
> 
> function jump() {
>   var x = 1374795.001;
>   var y = 5700582.001;
>   var z = 170.001; document.xnavigator.jumpToCoordinate(x,y,z);
> }

> Have you ever had an issue like this? Is there a workaround?
> How can I get control about variable's type?

Does the second format work in firefox on linux?

It looks like it may be a problem in the way ints and floats are handled 
by or handed to the applet.

If the second format works in all browsers, it may even work as:

function jump() {
  var x = 1374795.0;
  var y = 5700582.0;
  var z = 170.0;
  document.xnavigator.jumpToCoordinate(x,y,z);
}

in which case obviously the applet is loking for a float, not an "int or 
float", and appending .0 to an int is often sufficient to force the 
underlying code to treat it as a float (in many cases just appending "." 
is sufficient).

Rgds

Denis McMahon

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

function argument type Michele Da Ros <boeszyslak@gmail.com> - 2012-10-17 09:12 -0700
  Re: function argument type Denis McMahon <denismfmcmahon@gmail.com> - 2012-10-17 17:39 +0000
  Re: function argument type Danny <dann90038@gmail.com> - 2012-10-17 13:11 -0700

csiph-web