Go Back   CodingForums.com > Search Forums

Before you post, read our: Rules & Posting Guidelines

Showing results 1 to 25 of 28
Search took 0.11 seconds.
Search: Posts Made By: mjy
Forum: JavaScript programming 02-15-2012, 02:54 AM
Replies: 11
Views: 846
Posted By mjy
Hello craigr7, So you're saying that you...

Hello craigr7,

So you're saying that you want to activate page lengthening if location.hash is equal to any one of those three values? That would suggest an OR expression:

if (location.hash ===...
Forum: JavaScript programming 02-13-2012, 07:44 PM
Replies: 2
Views: 273
Posted By mjy
instance1.a = "a1"; instance2.a = "a2"; An...

instance1.a = "a1";
instance2.a = "a2";

An instance is not allowed to change the value of a property in its prototype -- attempting to do so defines a NEW locally defined property. (They're not...
Forum: JavaScript programming 02-10-2012, 05:47 PM
Replies: 2
Views: 540
Posted By mjy
Hello Echo773, I created a slideshow with...

Hello Echo773,

I created a slideshow with forward/back arrows plus a pause/resume button. It's at http://mjyonline.com/TL/TaosLand.htm. The JavaScript is contained right within the HTML page, and...
Forum: JavaScript programming 02-08-2012, 05:04 PM
Replies: 2
Views: 671
Posted By mjy
Math.random() (which does work!) returns a...

Math.random() (which does work!) returns a pseudorandom real number n, such that 0.0 <= n < 1.0. To get a random integer, say between 0 and 9 inclusive (for example to randomly index an array of 10...
Forum: JavaScript programming 02-07-2012, 03:28 AM
Replies: 2
Views: 396
Posted By mjy
I'm not sure, but what might be confusing you is...

I'm not sure, but what might be confusing you is that if a style has not yet been explicitly set through a style property assignment or through an inline style declaration (style="xxx" in the...
Forum: JavaScript programming 02-05-2012, 06:45 PM
Replies: 29
Views: 1,184
Posted By mjy
Hi Martin, My demo page just verifies that the...

Hi Martin,
My demo page just verifies that the correctForLeapYear() method works correctly. I don't know how you are actually using that method in your script. Maybe it never gets called.
Forum: JavaScript programming 02-05-2012, 06:02 PM
Replies: 29
Views: 1,184
Posted By mjy
I don't know how you're testing...

I don't know how you're testing correctForLeapYear(), but it seems to work fine for 2012:

<!DOCTYPE html>
<html>
<head>
<title>JavaScript Tester Page</title>

<script type="text/javascript"...
Forum: JavaScript programming 02-05-2012, 05:33 PM
Replies: 29
Views: 1,184
Posted By mjy
If you want to use your own algorithm, and...

If you want to use your own algorithm, and integrate it with your code, you might use the old leap-year algorithm I first saw in Kernighan & Ritchie, as follows:
...
Forum: JavaScript programming 02-04-2012, 05:25 PM
Replies: 11
Views: 846
Posted By mjy
As a simpler alternative, you might just...

As a simpler alternative, you might just highlight the target text, display an arrow next to it, or otherwise mark where the user should start reading. Here's a very simple prototype. Test.htm...
Forum: JavaScript programming 02-03-2012, 07:05 PM
Replies: 2
?
Views: 226
Posted By mjy
What version of FF are you testing? This code...

What version of FF are you testing? This code seems to work fine in IE9 and FF8. The following simplified version of this code also seems to work in these two browsers:

<script>...
Forum: JavaScript programming 02-02-2012, 02:21 AM
Replies: 8
Views: 1,029
Posted By mjy
I've tried to mark all the changes I made in red....

I've tried to mark all the changes I made in red. The output is as you indicated, except that it includes a $ sign.

<!DOCTYPE html>
<html>
<head>
<title>JavaScript Tester Page</title>

<!--...
Forum: JavaScript programming 01-31-2012, 03:56 PM
Replies: 9
Views: 768
Posted By mjy
Another way to deal with an object that might not...

Another way to deal with an object that might not exist, and avoid a runtime error, is to use JavaScript's try/catch mechanism. Say for example that you have defined an 'exists(obj)' function. The...
Forum: JavaScript programming 01-31-2012, 03:42 PM
Replies: 9
Views: 768
Posted By mjy
Although I don't understand the details of what...

Although I don't understand the details of what you're doing, it seems that your basic problem is that in JavaScript you can't reference a non-existent data item (e.g. pass it to an 'exists()'...
Forum: JavaScript programming 01-30-2012, 04:20 PM
Replies: 7
Views: 574
Posted By mjy
Here's an example link that should work (I...

Here's an example link that should work (I haven't tested it):

<div class="btns"><a href="#" class="button1" onclick="if (validate.check(document.form)) document.form.submit(); return false;">Send...
Forum: JavaScript programming 01-30-2012, 04:03 PM
Replies: 7
Views: 574
Posted By mjy
The problem with the second version of your code...

The problem with the second version of your code is not the reference to 'form' in 'document.form.submit()' That should work fine because you named the form "form." However, when you call the...
Forum: JavaScript programming 01-29-2012, 05:35 PM
Replies: 6
Views: 1,782
Posted By mjy
I'm surprised the original code works in IE,...

I'm surprised the original code works in IE, because location.href is a property that is supposed to be assigned the URL as a string, as is done in nomanic's code, which seems to work in IE and FF....
Forum: JavaScript programming 01-29-2012, 02:08 AM
Replies: 1
Views: 290
Posted By mjy
Sounds like something you could do using Ajax....

Sounds like something you could do using Ajax. Take a look at the Ajax demo I created (including source code) at http://mjyOnline.com/WebDemos.htm#weatherajax. It downloads weather data (in this...
Forum: JavaScript programming 01-28-2012, 02:20 AM
Replies: 2
Views: 493
Posted By mjy
Yes, if you just refresh the page in a...

Yes, if you just refresh the page in a window.onload handler (by calling window.location.reload()) you'll get an infinite loop of refreshes. To prevent this, you might use a cookie set to live only...
Forum: JavaScript programming 01-26-2012, 07:24 PM
Replies: 1
Views: 444
Posted By mjy
I'm not sure exactly what you want to do, but the...

I'm not sure exactly what you want to do, but the following code would set the image of the clicked link to the new image, and restore the image of the other link back to its default image:
...
Forum: JavaScript programming 01-25-2012, 01:41 AM
Replies: 5
Views: 573
Posted By mjy
Sorry to create the confusion. To simplify the...

Sorry to create the confusion. To simplify the discussion in my book I suggested just using the <!DOCTYPE html> HTML5 DOCTYPE together with document.documentElement.scrollLeft/Top (documentElement...
Forum: JavaScript programming 01-24-2012, 04:54 PM
Replies: 5
Views: 573
Posted By mjy
I'm not clear exactly what you're doing, but I...

I'm not clear exactly what you're doing, but I know that to position a <div> you would need to convert the screen coordinates (aka "viewport" coordinates) of the mouse pointer to document...
Forum: JavaScript programming 01-21-2012, 02:33 AM
Replies: 9
Views: 869
Posted By mjy
Another general reason to use insertBefore or...

Another general reason to use insertBefore or appendChild rather than innerHTML, is that innerHTML is a non-standard property. Although it's supported by all modern browsers, there are differences...
Forum: JavaScript programming 01-21-2012, 02:13 AM
Replies: 5
Views: 880
Posted By mjy
I'm not sure exactly what your requirements are,...

I'm not sure exactly what your requirements are, but a JavaScript package that I use called Highslide JS (from http://highslide.com) does what I think you want to do. You can create nice looking...
Forum: JavaScript programming 01-19-2012, 03:56 PM
Replies: 5
Views: 2,057
Posted By mjy
Using a cookie to store the last location is a...

Using a cookie to store the last location is a great idea. If you'd like me to send you example code for writing and reading cookies, taken from my book "JavaScript: Just the Basics," I'd be happy...
Forum: JavaScript programming 01-19-2012, 03:34 PM
Replies: 3
Views: 1,443
Posted By mjy
The expressions like \x67 are simply escape...

The expressions like \x67 are simply escape sequences, which you can embed in a string to encode characters that would be problematic to type in (or in this case, to obfuscate the text). The...
Showing results 1 to 25 of 28

 
Forum Jump

All times are GMT +1. The time now is 06:36 AM.