Im trying to use a .js file to store text that will be displayed in a small window. I tried to do a test in a regular window but i keep getting an error saying that my external variable is undefined. what am i doing wrong.
Below are the two files.
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT LANUAGE="JavaScript" SRC="mytext.js"></SCRIPT>
<SCRIPT LANUAGE="JavaScript" type="text/javascript">
<!--
var mytext = text;
-->
</SCRIPT>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<SCRIPT LANUAGE="JavaScript" >
<!--
document.write(mytext);
-->
</SCRIPT>
</body>
</html>
mytext.js (External .js file)
<!-- hide script from old browsers
var text ="this is the text that should be inserted into the window whenever This source file is called lets see if it works";
// end hiding script from old browsers -->
please can someone help.
SitePoint Member
Try taking the comments out of the .js file, and making it just the one line with your variable declaration:
---
var text ="this is the text that should be inserted into the window whenever This source file is called lets see if it works";
---
John,
leerie has solved this problem. He'd posted the query in another thread. He realised that he'd given the js file a .js.txt file extension.
Shane
SitePoint Member
Oh, OK. Thanks for letting me know.
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks