/    Sign up×
Community /Pin to ProfileBookmark

js file help

Hope I’m asking in the right place, and hope I ask the correct way… thanks

ok, I”m using a js and calling it to the html page. Problem is, I’m wanting to take one of the variable OUT of the js file and put it directly onto the webpage that’s calling the js file.

Not sure really how to explain this, but I set up an example of what I’m doing/want to do here;

[url]http://www.rhtubs.com/test1/test.htm[/url]

the tag <script src=”topmsg.js”></script> calls the script, BUT I want to take the first “var” (variable) OUT of the js file and add it to the html of the page. This would allow me to use the one js file throughout my site, but have minor differences from one web page to another.

Thank you so much!

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@JupacMay 15.2004 — In ypur head put

[code=php]<script type="text/javascript">
var blah = blah ;
</script>
<script type="text/javascript" src="yourfile.js"></script>[/code]
Copy linkTweet thisAlerts:
@PittimannMay 15.2004 — Hi!

Just define your variable in a script tag appearing above the one calling the js file:

<script language="JavaScript" type="text/javascript">

<!--

var myFirstVar='blahblah';

//-->

</script>

<script language="JavaScript" type="text/javascript" src="topmsg.js"></script>

Cheers - Pit

Edit: Hey, lakers01, you've been MUCH TOO FAST! ?
Copy linkTweet thisAlerts:
@letsauthorMay 15.2004 — YOU GUYS ROCK!!!!!!!!!!!!! thank you.

lakers01, yours seems to work fine if put in the body of the html, any problem with that (there's a little less coding in your version)?
Copy linkTweet thisAlerts:
@JupacMay 16.2004 — language="JavaScript" using that will not make it work in some browners and it is NOT VALID
Copy linkTweet thisAlerts:
@letsauthorMay 17.2004 — [i]Originally posted by lakers01 [/i]

[B]language="JavaScript" using that will not make it work in some browners and it is NOT VALID [/B][/QUOTE]


Understood....... Still have the question, can I put your code in the BODY rather than the HEAD (it works in my browser, not sure of the "rules" though for other browsers).


HEY! I REALLY appreciate your help. Thank you.
Copy linkTweet thisAlerts:
@JupacMay 18.2004 — i think you can
×

Success!

Help @lets spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.21,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...