Dragen Posted October 6, 2007 Share Posted October 6, 2007 Hi, I was just wondering about calling javascript variables. I'm not brilliant at javascript and I'm not sure what I'm trying to do can be done but here it is.. I have a javascript file which sets some variables: var width = screen.width; var height = screen.height; var ref = ""+document.referrer; var color = screen.colorDepth; I then have my html file which includes the javascript file: <body> <script type="text/javascript" src="javascript.js"></script> </body> Now what I'd like to do is write some javascript inside the script tags, which uses the variables set within the file.. for examplew: <body> <script type="text/javascript" src="http://localhost/counter/javascript.js"> document.write('ref: '+ref+'<br />colour: '+color+'<br />width: '+width+'<br />height: '+height); </script> </body> Please don't suggest just doing the document.write inside the javascript file itself.. I do have a reason for wanting it done like this Anyway.. anyone know of a possible way of doing this? I tried the code above and got nothing. Thanks Quote Link to comment Share on other sites More sharing options...
mainewoods Posted October 6, 2007 Share Posted October 6, 2007 <body> <script type="text/javascript" src="http://localhost/counter/javascript.js"></script> <script type="text/javascript"> document.write('ref: '+ref+'<br />colour: '+color+'<br />width: '+width+'<br />height: '+height); </script> --2 script tags, one with a src, one without. Both will be considered at the same level by the javascript parser. Quote Link to comment Share on other sites More sharing options...
Dragen Posted October 6, 2007 Author Share Posted October 6, 2007 thanks.. I hadn't thought of that I was also hoping just to do it in one tag though, to make it easier for people to use as it's a bit of code for clients to copy and paste into their pages. Thanks for the ever so simple answer! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.