Tag Archive for 'javascript'

When JavaScript and Flash aren’t playing well together

Making small changes to an existing website presents its own unique challenges, as ideally you’d like to change only what is absolutely necessary. When the previous builders have used their own CMS, and Javascript which was automatically generated by a Macromedia/Adobe product (oh, yes), not to mention a little flash thrown in for good measure, it can amount to basically reading pages of code to figure out what’s going on before you do anything.

In this case, when all was said and done, we had a Javascript dropdown menu which dropped over a little design element that had been done in flash. Problem was, the Flash always wanted to be overtop of the menu. Setting unreasonably high z-index properties for the menu elements did not seem to help.

Solution

This may or may not help others, but in this case the secret sauce was to add <param name="wmode" value="transparent"> among the other params, and also to add wmode="transparent" as an attribute in the embed tag for the Flash object.

I think a better solution would be to not use flash in this particular place — but I’m not really interested in fighting that battle this time.

Strange jQuery.load() behavior

In a site I’m working on, I was using jQuery’s load() function to insert content into a div from a navigational menu. Seemed pretty straight forward. The original code looked like this:

1
2
3
4
$(".some_class").click(function () {
		var link = $(this).attr("title");
		$("#div-content").load("some/path/" + link + "/index.php");
	});

Continue reading ‘Strange jQuery.load() behavior’

Crockford’s “Javascript: The Good Parts”

I know, I know. Conventional wisdom is that you should finish reading a book before you write a review of it. But since what follows should not be taken as a “book review” per se, I’m going to write it anyways.

Have just started reading Douglas Crockford’s new-ish book, Javascript: The Good Parts. In it, he states his intention to cover a functional sub-set of the Javascript language which he calls “the good parts.” The thesis is that you can program in Javascript using only The Good Parts, and that you’ll have a better time if you do.

So far, I’m really liking this book. So, for whatever that’s worth… yeah. No, the NYT will not be hiring me to do book reviews any time soon.

Clearing Form Fields with JQuery

I used a little jQuery last night to clear some form fields. The basic idea was, there were a couple text inputs in the form for first and last name; rather than label the fields, I made the value of each form to be initially “First” and “Last” respectively.

Then I was requested to make it so that when the field was clicked on, the word “First” or “Last” (respectively) would disappear, so that you could then proceed to enter a value without needing to highlight and delete the existing value of the text field.

It turns out that with jQuery, this is simple enough; let’s assume your field has the class “clearme”:
Continue reading ‘Clearing Form Fields with JQuery’

Processing.js

I have not even had time to play with this yet, but John Resig, creator of the excellent jquery Javascript library, has released Processing.js, a port of Processing to Javascript.

And there was much rejoicing.