PDA

View Full Version : create a js file


collie
04-17-2003, 02:50 AM
I need to learn how to create a js file so I can use a password protection script that Borgtex has submitted. I just need a turtorial if possible. thanks

Quiet Storm
04-17-2003, 02:55 AM
If the code looks like this:


<SCRIPT LANGUAGE="JavaScript">
document.write('BLAH!');
</SCRIPT>


Then you'll need to create a js page (call it example.js) and put this part in that new page:


document.write('BLAH!');

Then on the original page that had the entire script, do this:


<SCRIPT LANGUAGE="JavaScript" SRC="example.js">
</SCRIPT>

That's it!
:thumbsup:

collie
04-17-2003, 02:18 PM
That my confusion. I know how to create html pages but when you say js page (java script) that's were I'm looking for help. The files that I downloaded one was the js file (which I cant open) and the other was the login.html file below. I see the document write. So this is the code for the js file??



<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<title>Login</title>
<script type="text/javascript">
<!--
function authPass(u,p) {
if (u && p) self.location = "auth.htm?" + u + p;
return false;
}
// -->
</script>
</head>
<body>
<div>
<script type="text/javascript">
<!--
if (location.search.indexOf("auth=failed") != -1) {
document.write("<span style=\"color:#ff0000\">Authorization Failed!</span>");
}
// -->
</script>
<form id="form1" action="javascript://" onsubmit="return authPass(this.user.value,this.pass.value)">
<table>
<tr>
<td>Username: </td><td><input type="text" name="user" /></td>
</tr>
<tr>
<td>Password: </td><td><input type="text" name="pass" /></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Login" /></td>
</tr>
</table>
</form>
</div>
</body>
</html>:confused:

wyattwebb
04-17-2003, 04:26 PM
a .js file can be opened with any text editor like notepad. If you are trying to open the file by double clicking on it, it will try and run it. you need to open it through the file menu and then open.

A small file lesson for you. All files (in a windows environment) have an extention. For example .exe is an executable file, .html is a simple web page file. Each of these extentions have a program that is used to run them. Like .html runs in your browser.
Now to edit a .html file you must be using an editor like notepad or Frontpage. If you open the .js file in that same editor you should be ok.

The Login script you provided doesn't have any reference to a .js file. It looks like this is the result of the page running a filed login.

Quiet Storm has explained the rest.

:-)

collie
04-17-2003, 06:58 PM
That has been my whole problem. I know about file extensions,html,etc. I just could not open up the js. Now I can.
My FAULT. Was not thinking so I bothered you guys.

sage45
04-17-2003, 07:10 PM
No bother at all... Glad we could help... :)

-sage-