473,385 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

exit function

a bit of a 'hacker' with javascript but can any one tell me why this
code throws up "'exit' is undefined" and how to sort.

the code does what I want it to, but hate errors I can't explain.

TIA

R.

code is:

<script language="JavaScript">
//thanks to my mate geoff Taggart for this piece of code and style to round
//corners a la explorer 5.5
if (navigator.appName == 'Microsoft Internet Explorer' &&
parseInt(navigator.appVersion) >= 4){
document.write('<fieldset>');
exit;
}
else{
document.write('<fieldset class="moz_rad">');
exit;
}
</script>
Jul 20 '05 #1
4 28547
On Fri, 27 Feb 2004 01:16:17 +0000, highway of diamonds
<on*@oneandonly.com> wrote:
a bit of a 'hacker' with javascript but can any one tell me why this
code throws up "'exit' is undefined" and how to sort.
Because there is no such global variable, exit. There is no such global
function either. In fact, even if you use return, which can be used to
prematurely exit functions, it would serve no purpose as:

1) That code is not part of a function, and
2) The function would end after the 'else' clause anyway.
<script language="JavaScript">
The language attribute is deprecated. The type attribute is sufficient for
specifying the scripting language and, more importantly, it is required.

<script type="text/javascript">
if (navigator.appName == 'Microsoft Internet Explorer' &&
parseInt(navigator.appVersion) >= 4){


Browser detection is a bad idea. For instance, my browser, Opera 7.23,
will appear as IE according to that test if it is in spoofing mode.
Furthermore, this script appears to make your page dependent on support of
JavaScript that, depending on your execution environment, might not be
available.

However, without knowing what you're trying to acheive, there's no way to
suggest a better solution.

[snipped code]

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #2
highway of diamonds wrote:
a bit of a 'hacker' with javascript but can any one tell me why this
code throws up "'exit' is undefined" and how to sort.

the code does what I want it to, but hate errors I can't explain.

TIA

R.

code is:

<script language="JavaScript">
Should be:
<script type="text/javascript">

The language attribute is deprecated in HTML4.01, forbidden in others.
It is both forward and backwards compatible.

//thanks to my mate geoff Taggart for this piece of code and style to round
//corners a la explorer 5.5
You got what you paid for - nothing.
if (navigator.appName == 'Microsoft Internet Explorer' &&
parseInt(navigator.appVersion) >= 4){
http://www.jibbering.com/faq/#FAQ4_26

And stop trying to figure out my browser, you can't.

document.write('<fieldset>');
exit;
}
else{
document.write('<fieldset class="moz_rad">');
exit;
}
</script>


And to answer your question, its because its not "exit" you want. Either
break or return but you need neither. When it gets to the end of the
sequence in the if/else's, it "exits" on its own.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #3
<snip>

Thanks for that lads, have taken your points on board.

<blush> didn't realise I'd left Geoff's name in comments!</blush>

R.
Jul 20 '05 #4
highway of diamonds wrote:
a bit of a 'hacker' with javascript but can any one tell me why this
code throws up "'exit' is undefined" and how to sort.
The code throws up "'exit' is undefined" most likely because 'exit' is
undefined in that Javascript. It's not on the list of reserved words for the
language, and you haven't defined it anywhere.
the code does what I want it to, but hate errors I can't explain.
I doubt very much it actually does what you want it to. You appear to be
assuming there are two Web browsers in the world, IE 4 and higher versions, and
Mozilla-based browsers (based the "moz" part of 'class="moz_rad"').
TIA

R.

code is:

<script language="JavaScript">
//thanks to my mate geoff Taggart for this piece of code and style to round
//corners a la explorer 5.5
Of course, since IE doesn't support any of the Mozilla curve extensions, it's
enough to write:

<fieldset class="rad">
</fieldset>
<style type="text/css">
fieldset.rad {
-moz-border-radius: 10px;
}
</style>

or whatever. IE and other browsers that don't understand "-moz-border-radius"
will simply ignore it. No client-side Javascript required at all.
if (navigator.appName == 'Microsoft Internet Explorer' &&
parseInt(navigator.appVersion) >= 4){
document.write('<fieldset>');
exit;
}
else{
document.write('<fieldset class="moz_rad">');
exit;
}
</script>


--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Alex | last post by:
I am trying to write an Exit module for the Certification server in VB.NET and I cant get the module to be recognised by the Certification MMC snap in. Its function is to capture Serial Numbers of...
32
by: Protoman | last post by:
I have a function that calculates the mean of the some numbers; I need it to accept any number of parameters (one needs to be the number of the other parameters) Can you help me out here? Here's...
7
by: Darklight | last post by:
if the exit() function is contained in stdlid.h why if i remove the above header file the exit function still works and i can still compile program without any error messages using cc file.c if i...
17
by: jwaixs | last post by:
Hello, I was wondering, what's the difference between exit and return in the main() function? For me they both look the same, or aren't they? And if they aren't, which should I use in which...
6
by: orekin | last post by:
Hi There I have been trying to come to grips with Application.Run(), Application.Exit() and the Message Pump and I would really appreciate some feedback on the following questions .. There are...
3
by: darrel | last post by:
This might be a really dumb question, but when should/shouldn't one use the exit function command? If I have this: function() if something then do this return that else
20
by: lovecreatesbeauty | last post by:
Hello experts, Is the following code snippet legal? If it is, how can exit() do the keyword return a favor and give a return value to the main function? Can a function call (or only this...
16
by: Laurent Deniau | last post by:
I would like to know if the use of the pointer ref in the function cleanup() below is valid or if something in the norm prevents this kind of cross-reference during exit(). I haven't seen anything...
11
by: =?Utf-8?B?U3RldmVEQjE=?= | last post by:
Hi all. I'm using VS 2008 Express C++. I created a console application back in 1999, and updated it for VC++ 6.0 in 2001. I've updated again this past month, and have found enough differences...
39
by: mathieu | last post by:
Hi there, I am trying to reuse a piece of code that was designed as an application. The code is covered with 'exit' calls. I would like to reuse it as a library. For that I renamed the 'main'...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...

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.