Helpful Information
 
 
Category: JavaScript Development
Including files in Javascript

I want to pass a variable from a include file to a Javascript function which will be accessed by around 300 pages.
The url.txt contains
url=123.123.123.80
I included it as:
<!--#INCLUDE FILE="url.txt"-->
When i tried to access
function text(){
alert(url);
window.open("url/text.asp)}
This was not working.Can u pls send me the solution.

I think you need to do it like this -

Use this syntax to include your file, and make it a .js file -

<script language="javascript" src="filename.js"></script>

In your filename.js file do something like this -

var url="10.0.0.16";

You should then be able to reference the url variable from the main page. Hope that helps!

Matt.

Thanks a lot.It was very useful.










privacy (GDPR)