Danny Glover
Danny Glover

Reputation: 1

javascript to external .js file

Can't figure out the proper syntax to place this javascript code into a .js file.

<script type='text/javascript' src='http://hostedusa3.whoson.com:8080/include.js?domain=www.yourdomain.com'></script>    
<script type='text/javascript' >
if(typeof sWOTrackPage=='function')sWOTrackPage();
</script>

Upvotes: 0

Views: 134

Answers (2)

vol7ron
vol7ron

Reputation: 42095

external.js:

if(typeof sWOTrackPage=='function')sWOTrackPage();

in index.html:

<script type="text/javascript" src="external.js"></script>

If you want the other stuff in there to. Use your browser. Goto: http://hostedusa3.whoson.com:8080/include.js?domain=www.yourdomain.com copy that into external.js

Upvotes: 0

rvighne
rvighne

Reputation: 21877

If you want only the inline code inside a separate file, then all you have to do is move the contents of the second script tag into a .js file. Then, set the src attribute to the second <script> to reference the new file's URL (relative or absolute).

Upvotes: 1

Related Questions