I use the following javascript to time and close a window. I get the error: 'missing ( before formal parameters' on the
bold line below. Can anyone see why?
<script type="text/javascript">
var idle = true;
function window.onload() {
window.setTimeout("checkTimeout()", 10000);
}
function checkTimeout() {
if (idle) window.close();
window.setTimeout("checkTimeout()", 10000);
}
function document.onkeypress() {
idle = false;
}
</script>
Hello Jackxxx, Yes that script will work in JScript but will not work in Javascript. you could do this to make it work in both :)
instead of
function window.onload() {...
try this
window.onload = function() {...
and instead of
function document.onkeypress() {...
try this
document.onkeypress = function() {...
ok, the problem looks to be with this line
'function checkIBAN.prototype.removeNonValidChars(strIBAN_)....'
JScript (IE) allows you to declare functions using the dot notation ('function namespace.object.newMethodName() {}')
Javascript (Mozilla and others) does not allow declaring function names with any dot notation
So you could change the function declaration to this
checkIBAN.prototype.removeNonValidChars = function(strIBAN) { /* your implementation */ }; <- don't forget that semicolon
Just don't forget to add the semicolon to the end after the curly. It will work if it's the last thing before a carriage return, but if you compress your javascript (remove whitespace, carriage returns) then it will complain in both browsers since it doesn't
know where the statement ends.
Jackxxx
Contributor
3055 Points
2665 Posts
JavaScript Error missing ( before formal parmeters
Feb 22, 2008 04:51 PM|LINK
I use the following javascript to time and close a window. I get the error: 'missing ( before formal parameters' on the bold line below. Can anyone see why?
<script type="text/javascript"> var idle = true; function window.onload() { window.setTimeout("checkTimeout()", 10000); } function checkTimeout() { if (idle) window.close(); window.setTimeout("checkTimeout()", 10000); } function document.onkeypress() { idle = false; } </script>Jackxxx
Jeev
All-Star
24172 Points
3719 Posts
Re: JavaScript Error missing ( before formal parmeters
Feb 22, 2008 05:03 PM|LINK
Jack.. I tried your code and it seemed fine..and did not get any JS errors. I do not think this code snippet is the cause of the error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you get the answer to your question, please mark it as the answer.
Jackxxx
Contributor
3055 Points
2665 Posts
Re: JavaScript Error missing ( before formal parmeters
Feb 22, 2008 05:17 PM|LINK
I have been testing our app with FireFox and FireBug, FireBug found the error, IE does not.
Jackxxx
Hong-Gang Ch...
All-Star
74695 Points
6767 Posts
Microsoft
Re: JavaScript Error missing ( before formal parmeters
Feb 27, 2008 07:35 AM|LINK
Hi Jackxxx,
What is error? You can search the error online, maybe you can easy find the answer.
OR:
Please post the whole code here if the problem remains unsolved.
Waiting for your feedback,
Hong Gang
If you have any feedback about my replies,please contactmsdnmg@microsoft.com.
Microsoft One Code Framework
fatfrank5
Member
2 Points
1 Post
Re: JavaScript Error missing ( before formal parmeters
Apr 25, 2008 06:48 PM|LINK
I'm also experiencing the same issue as you.. :(
It only happens in FireFox and not IE. Any time I try to create a function with a dot. eg
var a = {};
a.someMethod = function(){};
Juztin
Member
6 Points
3 Posts
Re: JavaScript Error missing ( before formal parmeters
May 14, 2008 07:11 AM|LINK
instead of
function window.onload() {...
try this
window.onload = function() {...
and instead of
function document.onkeypress() {...
try this
document.onkeypress = function() {...
That should work in both JScript and Javascript..
Juztin
Member
6 Points
3 Posts
Re: JavaScript Error missing ( before formal parmeters
May 14, 2008 11:00 PM|LINK
I posted a bit more information in a blog post here :) Hope this helped
http://juztinwilzon.blogspot.com/2008/05/missing-before-formal-parameters.html
ivobrabec
Member
4 Points
2 Posts
Re: JavaScript Error missing ( before formal parmeters
May 23, 2008 11:21 AM|LINK
I read your explanation on this error as I am experiencing similar problem. But I was not able to implement your help to my case...
I have this code
<script src=http://www.etsmoney.com/scripts/iban.js type="text/javascript"></script>
<script>
<!--
{
var oIBANcheck=new checkIBAN(document.form,"iban");
}
//-->
</script>
In IE it works, in Mozzila it gives the folowin error:
Error: missing ( before formal parameters
Source File: http://www.etsmoney.com/scripts/iban.js
Line: 21, Column: 18
Source Code:
function checkIBAN.prototype.removeNonValidChars(strIBAN_)
I cannot figure out what is the problem.
Thanks for your help.
Ivo
Juztin
Member
6 Points
3 Posts
Re: JavaScript Error missing ( before formal parmeters
May 24, 2008 09:04 PM|LINK
'function checkIBAN.prototype.removeNonValidChars(strIBAN_)....'
JScript (IE) allows you to declare functions using the dot notation ('function namespace.object.newMethodName() {}')
Javascript (Mozilla and others) does not allow declaring function names with any dot notation
So you could change the function declaration to this
checkIBAN.prototype.removeNonValidChars = function(strIBAN) { /* your implementation */ }; <- don't forget that semicolon
Just don't forget to add the semicolon to the end after the curly. It will work if it's the last thing before a carriage return, but if you compress your javascript (remove whitespace, carriage returns) then it will complain in both browsers since it doesn't know where the statement ends.
ivobrabec
Member
4 Points
2 Posts
Re: JavaScript Error missing ( before formal parmeters
May 25, 2008 05:34 AM|LINK