473,573 Members | 3,524 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling Javascript in Firefox

20 New Member
Hi there.

I'm putting together a page to collect some information from our website users and send the administrator an email. To this end I have some Javascript form validation in an external file, activation.js. I have put a script tag in the header, and everything works fine in Internet Explorer 7 and Opera 9.

However, the script is not being called in Firefox 2. I can tell that the script is not being called because I put a window.alert(); statement in, both in the seperate .js script file and in a completely seperate script statement in the html file itself.

At the moment, the header looks like this:

Expand|Select|Wrap|Line Numbers
  1. <head>
  2. <title>User Information Request</title>
  3. <meta name="Generator" content="EditPlus" />
  4. <meta name="Author" content="davidiwharper@hotmail.com" />
  5. <meta name="Keywords" content="" />
  6. <meta name="Description" content="" />
  7.  
  8. <link rel="stylesheet" type="text/css" href="http://www.our-website.com/style/main.css" media="screen"> 
  9.  
  10. <script language="JavaScript" type="text/javascript" src="activation.js">
  11.  
  12. // Script to validate form
  13.  
  14. </script>
  15.  
  16. <script language="JavaScript" type="text/javascript">
  17.  
  18. window.alert();
  19.  
  20. </script>
  21. </head>
  22.  
This works fine in IE and Opera, but not in Firefox. Javascript is definitely enabled in Firefox -- I've been to a test page here and it works fine.

What am I doing wrong?
Mar 13 '07 #1
6 1879
dorinbogdan
839 Recognized Expert Contributor
I ran your html (with empty body) in Firefix 2.0 with no problems, using as
activation.js with just one line:
Expand|Select|Wrap|Line Numbers
  1. alert("Hello from activation.js file!");
So, the problem could be in your activation.js code.
Mar 13 '07 #2
davidiwharper
20 New Member
Hi there,

Thanks for the response.

I've stripped out all of the foreign HTML (there is a lot of PostNuke formatting), and also the reference to external script in the header.

The page now looks like this:

Expand|Select|Wrap|Line Numbers
  1. <head>
  2. <title>User Information Request</title>
  3. <meta name="Generator" content="EditPlus" />
  4. <meta name="Author" content="davidiwharper@hotmail.com" />
  5. <meta name="Keywords" content="" />
  6. <meta name="Description" content="" />
  7.  
  8. <script language="JavaScript" type="text/javascript">
  9.  
  10. window.alert();
  11.  
  12. </script>
  13.  
  14. </head>
  15.  
  16. <body>
  17.  
  18.     <table>
  19.     <tr>
  20.         <td>&nbsp;</td>
  21.         <td><h1>Account Activation</h1></td>
  22.         <td>&nbsp;</td>
  23.     </tr>
  24.     <tr>
  25.         <td>&nbsp;</td>
  26.         <td>
  27.  
  28.             <p>This page will allow you to file an activation request for your church user account. Once your account is activated, you will be able to access additional content on the main church website.</p>
  29.             <p>Activation requests will only be approved if you have previously entered your contact details on the Church Roll, and have completed the registration process on the main website.</p>
  30.             <p>Please fill out the following information:</p>
  31.  
  32.             <form method="post" action="/cgi-bin/activate.pl" >
  33.  
  34.             <p><table>
  35.             <tr>
  36.                 <td>Full Name:</td>
  37.                 <td><input type="text" name="fullname" size="31" /></td>
  38.             </tr>
  39.             <tr>
  40.                 <td>Street Address:</td>
  41.                 <td><input type="text" name="address" size="31" /></td>
  42.             </tr>
  43.             <tr>
  44.                 <td>Email Address:</td>
  45.                 <td><input type="text" name="email" size="31" /></td>
  46.             </tr>
  47.             <tr>
  48.                 <td>Website User Name: </td>
  49.                 <td><input type="text" name="username" size="31" /></td>
  50.             </tr>
  51.             </table></p>
  52.  
  53.             <p><button type="submit">Submit</button></p>
  54.  
  55.             </form>
  56.  
  57.         </td>
  58.         <td>&nbsp;</td>
  59.     </tr>
  60.     </table>
  61.  
  62. </body>
  63. </html>
  64.  
Still no joy with this page.

Here is activation.js, by the way:

Expand|Select|Wrap|Line Numbers
  1. var existingEmail;
  2.  
  3. function unpackCookie() {
  4.  
  5.     /* Gets information ready for use on the form */
  6.  
  7.     if (document.cookie) {
  8.  
  9.         // Unpack the cookie
  10.  
  11.         var thePairs = document.cookie.split("; ");
  12.         var actualName = thePairs[0].split("=");
  13.         var homeAddress = thePairs[1].split("=");
  14.         var emailAddress = thePairs[2].split("=");
  15.         var userName = thePairs[3].split("=");
  16.  
  17.         // Pre-populate the fields to show that we remember you
  18.  
  19.         document.getElementById("fullname").value = actualName[1];
  20.         document.getElementById("address").value = homeAddress[1];
  21.         document.getElementById("email").value = emailAddress[1];
  22.         document.getElementById("username").value = userName[1];
  23.  
  24.         // Put the existing email address into memory
  25.  
  26.         existingEmail = emailAddress[1];
  27.  
  28.     }
  29.  
  30. }
  31.  
  32. function checkform() {
  33.  
  34.     /* Get the data from the form */
  35.  
  36.     var nText = document.getElementById('fullname').value;
  37.     var aText = document.getElementById('address').value;
  38.     var eText = document.getElementById('email').value;
  39.     var uText = document.getElementById('username').value;
  40.  
  41.     if (eText == existingEmail)
  42.     {
  43.  
  44.         // An activation reqest has already been submitted for this address
  45.  
  46.         window.alert("Please do not submit\nduplicate activation requests!");
  47.         return false;
  48.  
  49.     }
  50.  
  51.     /* Checks that all details have been entered */
  52.  
  53.     if (nText == "" || aText == "" || eText == "" || uText == "" ) {
  54.  
  55.         // The form is incomplete
  56.  
  57.         window.alert("Please fill in all of your contact details.");
  58.         return false;
  59.  
  60.     }
  61.  
  62.     /* Now we will make a cookie so that users cannot resubmit their request */
  63.  
  64.     var today = new Date();
  65.     today.setMonth(today.getMonth()+12);
  66.     expiryDate = today.toUTCString();
  67.  
  68.     document.cookie="actualName=" + nText + "; expires=" + expiryDate;
  69.     document.cookie="homeAddress=" + aText + "; expires=" + expiryDate;
  70.     document.cookie="emailAddress=" + eText + "; expires=" + expiryDate;
  71.     document.cookie="userName=" + uText + "; expires=" + expiryDate;
  72.  
  73.     /* Passed all checks */
  74.  
  75.     return true;
  76.  
  77. }
  78.  
Thanks again!
David
Mar 14 '07 #3
dorinbogdan
839 Recognized Expert Contributor
Did you remove the reference to the activation.js from the html file?
Mar 14 '07 #4
dorinbogdan
839 Recognized Expert Contributor
Replace the "name" attribute by "id", for all input boxes, like:
[html]<td><input type="text" id="fullname" size="31" /></td>
...[/html]
since in activation.js appears:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("fullname").value = actualName[1];
  2. ...
Mar 14 '07 #5
davidiwharper
20 New Member
Replace the "name" attribute by "id", for all input boxes
That worked like a charm.

Thanks!! :-)
Mar 14 '07 #6
dorinbogdan
839 Recognized Expert Contributor
Glad to hear that.
God bless you.
Mar 14 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
3616
by: nec | last post by:
Hi, I'm having trouble calling a function thats located in a iFrame from the parent. Shortly, i can't figure out the location in DOM. In IE it works fine with a simple line of window.contens.alerter('wassa?'), but it doesnt, of course work in Firefox (0.8). I've tried document.getElementById('contens').alerter('wassa?') and
11
1752
by: JS | last post by:
I have made a function createFirstMenu where I call "resetMenu" in a JavaScript. But nothing happens when I call resetMenu. function createFirstMenu(sel){ sel = document.getElementById('sel1'); resetMenu(sel); } function resetMenu(sel){ sel.length = 0;
2
9515
by: Blondie21 | last post by:
Hi, I have a .jsp file in the following format: .... html headers, jsp code, html code... <jsp:plugin type="applet" code="path.in.packet.appletclassname.class" codebase=".." jreversion="1.5"
1
1758
by: bbammes | last post by:
I'm writing a click tracking program which calls a remote PHP script when a user clicks a link. My javascript is: <script type="text/javascript"> //<! ); ?>&clientaddress=<?php echo urlencode( $_SERVER ); ?>"; } return true; } //]]>
3
2186
by: Kenneth McDonald | last post by:
I know that there's some work out there to let Python make use of Javascript (Spidermonkey) via (I assume) some sort of bridging C/C++ code. Anyone know of efforts to allow the reverse? I'd really like to make use of Python when doing Mozilla DOM programming, and I can never get a clear idea of when PyXPCOM might be available to those of us...
8
8927
by: wpelgrum | last post by:
When I open a webpage with javascript my browser (both IE6 and FF2.0.0.3) freezes anywhere from seconds to more than a minute. During that period, the browser is frozen and windows (XP-SP2) is very poorly responsive. There is no significant CPU-load. When I disable javascript in FireFox, everything works smoothly again. I have...
1
2405
by: Memphis Steve | last post by:
Is it possible to combine multiple javascipts into one file and then call that file from a linked URL in the head section of an XHTML file? Here are the two scripts I want to use with the instructions on where to normally place them in an XHTML document: SCRIPT #1: Step 1: Insert the below anywhere into the <body> section of your page...
4
2451
by: r_ahimsa_m | last post by:
Hello, I am learning WWW technologies in Linux. I created index.html file which I can browse with Firefox/Konqueror using URL localhost/~robert/rozgloszenia/index.html. The page looks fine but there's one strange problem: I have written some JavaScript code in functions.js file which seems to be ignored when called although I have JavaScript...
18
1819
by: dhtml | last post by:
Array.splice({}) What should it do? I think it should return a new Array with length 0. Array.splice(arr, start, deleteCount ]]) http://bclary.com/2004/11/07/#a-15.4.4.12 Example:
0
7789
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8037
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8086
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6432
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5605
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5296
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3737
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3743
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.