|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Display variable within an external .js file
I just started working with javascript a few weeks ago. If i create an external javascript file with the following
var maintext="This text needs to be displayed" and save it as "external.js" What code do i need to put in an html document to display this variable? is the syntax for the javascript file correct? |
|
#2
|
||||
|
||||
|
js vars
If you reference the external file in the page's head section, the variable will be available to subsequent javascript.
To test it, you could use another in-page script that "alerts" it. A simple way would be to "document.write" it wherever you want it to appear. But the correct way to do this would be to have some in-head script modify the DOM |
|
#3
|
|||
|
|||
|
Quote:
Thanks man, that was just what I was lookin for. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > Display variable within an external .js file |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|