By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
461,955 Members | 707 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 461,955 IT Pros & Developers. It's quick & easy.

Running JavaScript file from HTML body?

P: 2
Hi all, :)

Thanks in advance for all help and please excuse me if this question has been asked a million times before.

- Bob


Within the body of an HTML file I am currently using the following code:
<script language="JavaScript" src="message.js"></script>
to load a text message into my page.

The code successfully loads the following file:
document.write('This is the message');
and displays This is the message on the web page.

My question is:
I'd like to be able to run JavaScript from inside the file instead of just text. Can it be done? (it must be done with JavaScript and not SSI or another method)

Specifically, I want to be able to run the following code from within the js file so that I don't have to place it directly in the HTML:

<script type="text/javascript"><!--
google_ad_client = "pub-7201111111111111";
google_ad_width = 110;
google_ad_height = 32;
google_ad_format = "110x32_as_rimg";
google_cpa_choice = "CAAQlNuI_AEaCIITj2hUxSIQKJDGrIMB";
google_ad_channel = "4400000002";
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>


Once again, thanks in advance.
Aug 11 '06 #1
Share this Question
Share on Google+
2 Replies

iam_clint
Expert 100+
P: 1,208
Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript" src="googlad.js"></script>
  2. <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
  3. </script>
  4.  
see what i did just make basicly 2 "includes" kind of.. should work how you want it to.
Aug 11 '06 #2

P: 2
That definitely works! Thanks so much Clint.
Aug 11 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.