473,386 Members | 1,733 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,386 software developers and data experts.

JavaScript Tutorial

Hello Everybody,

I am writing an interactive tutorial for JavaScript.
I created a text box into which the users can input
javascript commands. On pressing a button, these commands
will be evaluated.

It works fine - but won't show any error if the commands
are wrong. Is there a way to show an error if the 'eval'
command encounters an error?

You can check out this tutorial at
http://www.geocities.com/binnyva/cod...ial/index.html

This tutorial is to completely finished - so if you have any
suggetions/comments please let me know. If you think that I
have left out something important please send me a note
and I will see to the problem.
Thanks in Advance,
Binny V A
http://www.geocities.com/binnyva

Jul 23 '05 #1
4 1668
bi*****@hotmail.com wrote:
[snip]

You can check out this tutorial at
http://www.geocities.com/binnyva/cod...ial/index.html

This tutorial is to completely finished - so if you have any
suggetions/comments please let me know. If you think that I
have left out something important please send me a note
and I will see to the problem.


You know that it works only in IE Windows?
You may want to learn how to reference a form control.

document.formName.elementName (dot notation)
Mick
Jul 23 '05 #2
wrote on 12 jan 2005 in comp.lang.javascript:
I am writing an interactive tutorial for JavaScript. Is there a way to show an error if the 'eval'
command encounters an error? This tutorial is to completely finished


How can it be finished, if you still have a question about JS?
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #3
bi*****@hotmail.com wrote:
Hello Everybody,

I am writing an interactive tutorial for JavaScript.

<snip>

<quote
cite="http://www.geocities.com/binnyva/code/javascript/basic_tutorial/va
riables.html">
JavaScript is a loose typing language. So you don't have to declare the
variables. But there is an option to do so. Use 'var' in front of the
variable you wish to declare - but you can leave that out if you don't
wish to work you fingers unnecessary.
</quote>

Tutorial or practical joke?

Richard.
Jul 23 '05 #4
rh
bi*****@hotmail.com wrote:
Hello Everybody,

I am writing an interactive tutorial for JavaScript.
I created a text box into which the users can input
javascript commands. On pressing a button, these commands
will be evaluated.

That's not exactly a new idea, but it has merit nonetheless.
It works fine - but won't show any error if the commands
are wrong. Is there a way to show an error if the 'eval'
command encounters an error?

If the user of your tutorial is running a modern browser, one that
supports the ECMA-262 Javascript standard, you can use the try-catch
constructs of the language to provide infomation about errors that may
occur during execution.

The problem is that not everyone runs up-to-date browsers, and
inclusion of try-catch will cause syntax errors when encountered in the
older browsers. The following example may provide a way to capture
errors in most browsers without causing syntax error grief in browsers
that don't support try-catch :

(/**/ prefixes the lines in order to maintain code formatting in this
posting)

<script type="text/javascript">
/*JRS*/
/**/ var checkTry = "try {}catch(e){}";
/**/ var testText = "This cannot be successfully executed!";

/**/ var EVAL;

/**/ var ahhFutz = function() { // try/catch is not available
/**/ EVAL = function (code) { eval(code) };
/**/ window.onerror = function(msg) { // Output message on error
/**/ alert( "Execution failed: "+msg);
/**/ }
/**/ // Wait for an event
/**/ }

/**/ window.onerror = ahhFutz;
/**/ eval (checkTry); // See if try/catch is available

/**/ EVAL = new Function("code", // try/catch is available, so use it
/**/ 'try { '
/**/ +' eval(code); '
/**/ +'} '
/**/ +'catch (e) {'
/**/ +' alert( "Execution failed for :"+code+'
/**/ +' "\\n\\n"+(e.message || e.description ) );'
/**/ +'}'
/**/ );
/*JRS*/

EVAL(testText);
</script> You can check out this tutorial at
http://www.geocities.com/binnyva/cod...ial/index.html
This tutorial is to completely finished - so if you have any
suggetions/comments please let me know. If you think that I
have left out something important please send me a note
and I will see to the problem.


I like the humerous approach in the tutorial. However, as pointed out
in earlier posts, it appears that you have some learning and work to do
yet (as an example, note that the ++ and -- operators can be both
prefix and postfix, and may have considerably different effects
depending on their placement relative to the operand).

../rh

Jul 23 '05 #5

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

Similar topics

3
by: Anonymous | last post by:
Hello folks -- I would like a JavaScript tutorial for programmers. By this I mean that I'd like to know the language "fundamentals" /first/ and then learn about the "web stuff". This is because...
2
by: svend | last post by:
Hey everyone, I've written a tutorial to the Venkman debugger for Mozilla <http://www.mozilla.org/projects/venkman/>. It covers all features that I'm aware of, and most importantly, it's written...
15
by: binnyva | last post by:
Hello Everyone, I have just compleated a JavaScript tutorial and publishing the draft(or the beta version, as I like to call it) for review. This is not open to public yet. The Tutorial is...
2
by: Alan Searle | last post by:
I would like to use an XSL/HTML template to sort XML data dynamically on the client side. As it is, I found a tutorial showing how to do this on the following site ... ...
2
by: Water Cooler v2 | last post by:
http://www.w3schools.com/js/js_whereto.asp This link is to a JavaScript tutorial on w3schools. The page says that a script put in the HEAD is executed only when called, whereas one put in the...
2
by: Turbo | last post by:
Here is small javascript that i aggregated using various sources from web. Please comment if you find it useful. http://sandy007smarty.seo.iitm.ac.in/2006/09/26/javascript-tutorial/
9
by: mshepard | last post by:
I am very new to Javascript and would like some advise for the following... a. Declare a variable named rNumber = to the value returned from the randInt() function using 5 as the parameter value. ...
23
Frinavale
by: Frinavale | last post by:
JavaScript is a very strange place for me... So, I decided that, before I attempt to create an Object, I should first learn about Objects. I had actually created one before with the help of a...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...

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.