RayT Posted May 2, 2006 Share Posted May 2, 2006 Working from 'JavaScript for Dummies' I have modified the listing 4-5 to change the font-sizes of a large page of text to small, medium and large. It works well but uses several lines of <script>.....</script> within the header:function changeTheme() { switch(document.myForm.themes.selectedIndex) { case 0: document.getElementById("graf1").style.fontSize="small"; break; case 1: document.getElementById("graf1").style.fontSize="medium"; break; case 2: document.getElementById("graf1").style.fontSize="large"; break; }}Question: can I safely embed this routine within my CSS file? - and if so how? please. Link to comment Share on other sites More sharing options...
scott100 Posted May 2, 2006 Share Posted May 2, 2006 Can you put javascript in css? noyou could put the javascript in an external script file. Link to comment Share on other sites More sharing options...
RayT Posted May 2, 2006 Author Share Posted May 2, 2006 Can you put javascript in css? noyou could put the javascript in an external script file.<{POST_SNAPBACK}> Thanks, but I've trawled the websites and textbooks but cannot find what an external script file looks like! Does it have HTML headers etc?I've tried saving raw javascript code as a .js file and calling from the web page but with no functionality!RayT Link to comment Share on other sites More sharing options...
Little Goat Posted May 2, 2006 Share Posted May 2, 2006 ok, take everything that is inside the <script> tags and put it in another file named somefile.js . then in you page where the script used to be put this: <script type="text/javascript" src="somefile.js"></script> LG Link to comment Share on other sites More sharing options...
RayT Posted May 2, 2006 Author Share Posted May 2, 2006 ok, take everything that is inside the <script> tags and put it in another file named somefile.js . then in you page where the script used to be put this:<script type="text/javascript" src="somefile.js"></script> LG <{POST_SNAPBACK}> Bingo! Works perfectly. Help much appreciated - obvious once you know!RayT Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now