简体   繁体   中英

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>

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).

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM