ReferenceError

21 views
Skip to first unread message

raja ammar

unread,
Apr 5, 2015, 8:17:42 AM4/5/15
to nod...@googlegroups.com
Hi ;
My project is devised on 3 files. I declared  a variable in file.js and i have to use this variable in file.html.how can i send this variable to file.html without declaration in this file?
In fact the error is ReferenceError: ua is not defined.
please can you help me.
Thanks.

Aria Stewart

unread,
Apr 5, 2015, 8:26:30 AM4/5/15
to nod...@googlegroups.com

That doesn't sound like a node.js question -- more like browser javascript. This list isn't really the place for browser javascript questions, but let's see if this helps.

If it is indeed a browser question, you can use variables like that globally by making them properties of window:

window.ua = whatever

Also variables at the top level (not wrapped in a function) in plain browser javascript are shared, so just the declaration will work.

However, if you use a module system like browserify, everything is wrapped in functions, so that doesn't work and you have to use the global "window" object.

Aria

Adrien Risser

unread,
Apr 5, 2015, 8:26:35 AM4/5/15
to nod...@googlegroups.com
Hi,

You'll probably better off with Meteor, a complete web framework with client / server sharing of data.
It is quick to setup and you'll be up and running within minutes.


Cheers,

--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
To post to this group, send email to nod...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/d4b4ddac-2c79-4150-89ff-0bf04e0a55ce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Adrien Risser,
Freelance Node.js Consultant
Reply all
Reply to author
Forward
0 new messages