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


Groups > comp.lang.javascript > #15604 > unrolled thread

javascript in another file

Started byjags <jagatm@gmail.com>
First post2012-08-29 10:14 -0700
Last post2012-08-30 05:28 -0700
Articles 4 — 2 participants

Back to article view | Back to comp.lang.javascript


Contents

  javascript in another file jags <jagatm@gmail.com> - 2012-08-29 10:14 -0700
    Re: javascript in another file Stefan Weiss <krewecherl@gmail.com> - 2012-08-29 22:38 +0200
      Re: javascript in another file jags <jagatm@gmail.com> - 2012-08-30 04:01 -0700
        Re: javascript in another file jags <jagatm@gmail.com> - 2012-08-30 05:28 -0700

#15604 — javascript in another file

Fromjags <jagatm@gmail.com>
Date2012-08-29 10:14 -0700
Subjectjavascript in another file
Message-ID<20299183-1ca3-4cd2-b17e-0cc86bf59f22@googlegroups.com>
i am trying to do like this


js file


var myvar = 
{
 myfunc1: function {},
myfunc2: function{}
};

in html file i include this script through src

then on body onload i call myvar.myfunc1;

in crome dev console i see error near var, why so ?

[toc] | [next] | [standalone]


#15610

FromStefan Weiss <krewecherl@gmail.com>
Date2012-08-29 22:38 +0200
Message-ID<k1luku$8ce$1@news.albasani.net>
In reply to#15604
On 2012-08-29 19:14, jags wrote:
> var myvar = 
> {
>  myfunc1: function {},
> myfunc2: function{}
> };

That's a syntax error. Should be
...
  myfunc1: function () {},
  myfunc2: function () {}
...

> in html file i include this script through src
> 
> then on body onload i call myvar.myfunc1;
> 
> in crome dev console i see error near var, why so ?

You could start by telling us what the error message said.

- stefan

[toc] | [prev] | [next] | [standalone]


#15616

Fromjags <jagatm@gmail.com>
Date2012-08-30 04:01 -0700
Message-ID<3467f210-aa11-4f8d-8e1f-fd51c3b9aa15@googlegroups.com>
In reply to#15610
it is saying "Syntax Error: Unexpected token var"

but why is it a syntax error ? in another example it just works fine !
i picked it from there, just changed names !

[toc] | [prev] | [next] | [standalone]


#15617

Fromjags <jagatm@gmail.com>
Date2012-08-30 05:28 -0700
Message-ID<9f9f4fce-802d-4010-b37b-9302464240d5@googlegroups.com>
In reply to#15616
On Thursday, August 30, 2012 4:31:03 PM UTC+5:30, jags wrote:
> it is saying "Syntax Error: Unexpected token var"
> 
> 
> 
> but why is it a syntax error ? in another example it just works fine !
> 
> i picked it from there, just changed names !

ok, sorry, it was showing error at myFunc1(var dataString)

i changed it to myFunc1(dataString) and it worked :)

thanks

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web