javascript

A working Json library for Javascript?

I went to http://www.json.org/js.html and downloaded the json2.js, thinking i'd be fine, afterall that site is on the top in a google search for 'json javascript' - also they have this really cool url :) So i've been working a bit with it and it seemed fine, but now i start running into trouble with it - it simply won't parse certain st...

javascript Rich Text Editors

There are several (very good) rich text web editors written in Javascript (eg FCKeditor, YUI Texteditor and many many others). However I couldn't find any tutorial on how to build such a component. Something that would explain both high-level considerations (architecture) and/or more details in low-level "critical" points (ie why do mos...

Is there a documented JavaScript API for Windows Media Player?

I want to use JavaScript to control an embedded Windows Media Player, as well as access any properties that the player exposes. I've found a few hacky examples online, but nothing concrete. I really need access to play, pause, stop, seek, fullscreen, etc. I'd also like to have access to any events the player happens to broadcast. Hel...

Good tool to minimize HTML footprint?

Does anyone know a good tool that can be run on a page (for asp.net, for example) to help to minimize the footprint size of the page? The page will have typical items: HTML, Javascript, etc. I've heard of Javascript crunchers in the past, that will make the size of the code as compact as possible (and obfuscate it, I suppose). The goa...

Java Servlet : How to detect browser closing ?

In my web app, when a user logs in, I add his Id to a vector of valid Ids in the servlet, when he logs out, I remove his Id from the vector, so I can see how many current users are active, if a user forgets to log out, my servelt generated html has : <meta http-equiv="Refresh" content="30; url=My_Servlet?User_Action=logout&User_Id=1111...

Javascript to flash communication

Hello, I am trying to call a Actionscript function from javascript but I am having problems in Internet Explorer. I am using Swiff.remote in mootools 1.2.1 to call the actionscript function ie: Swiff.remote(playSwf.toElement(), 'sendResult', result, plays, name); This all works fine in FireFox, Safari and Opera but I'm getting an "un...

How do you check if a selector exists in jQuery?

In Mootools, I'd just run if ($('target')) { ... }. Does if ($('#target')) { ... } in jQuery work the same way? ...

How do I wrap a span around a section of text in javascript?

I have markup like this: <p>one two three four</p> And I want to use javascript to convert it to this: <p>one <span>two three<span> four</p> I have the offset and length of the section I want to wrap in a span, in this case offset = 4 and length = 9. If using jQuery can make it easier, that is preferable. ...

Google Chrome - javascript version

What version of javascript does Google Chrome support in relation to Mozilla Firefox? In other words, does Chrome support javascript 1.6, 1.7, or 1.8 from Firefox or some combination of them? ...

Javascript frames discovery

In javascript how do I get a handle on the frame that I'm in based on an element in that frame? function myFunction(elementInFrame){ // here I want to get a handle on the frame that elementInFrame lives in } ...

How to get container of draggable inside drop event?

I have an html like this: <div id="container1"> <div class="dragme">drag me</div> </div> <div id="container2"> <div class="dragme">drag me</div> </div> <div id="droponme"></div> $(".dragme").draggable(); $("#droponme").droppable({ accept: ".dragme", drop: function(e, u) { alert( /* find id of the container here*/ ); }; ...

How do I execute JS XHR responses in Dojo?

What I'm looking for looks like this in jQuery: jQuery.ajaxSetup({ 'beforeSend': function(xhr) { xhr.setRequestHeader("Accept", "text/javascript"); } }); ... $("#my_form").submit({ $.post($(this).attr("action", $(this).serialize(), null, "script"); return false; }); Then, when my server returns some Javascript (the Accept-...

Where do you put your javascript?

Do you localize your javascript to the page, or have a master "application.js" or similar? If it's the latter, what is the best practice to make sure your .js isn't executing on the wrong pages? EDIT: by javascript I mean custom javascript you write as a developer, not js libraries. I can't imagine anyone would copy/paste the jQuery so...

How to Include Multiple Javascript Files in .NET (Like they do in rails)

I'm jealous of the rails guys. They can do this: <%= javascript_include_tag "all_min" %> ... and I'm stuck doing this: <script src="/public/javascript/jquery/jquery.js" type="text/javascript"></script> <script src="/public/javascript/jquery/jquery.tablesorter.js" type="text/javascript"></script> <script src="/public/javascript/jquery...

How to find slow-down in Javascript in IE6

Something's slowing down my Javascript code in IE6 to where there's a noticeable lag on hover. It's fine in FF, so using firebug isn't that helpful. What tools are out there to help debug this in IE? ...

How do I include HTML in a JS Rails response?

I have a FooController that responds to HTML and JS (AJAX) queries: # app/controllers/foo_controller.rb: class FooController < ApplicationController layout 'foo' def bar respond_to do |format| format.html # foo/bar.html.erb format.js # foo/bar.js.erb end end end The templates to support it: # app/views/lay...

Client side modal dialog in asp.net from the server side code. (how do I do this)

I need a technique for dealing with what seems pretty simple! I have a form, with some logic on the server side for validation. if the server side code indicates that there is an issue, I want to display a modal popup to the client. I am having trouble getting it to work in this way. I found if I keep all the logic client side, I can ...

Script for College Class Registration

I sign up Spring courses tomorrow morning (transferring in to the Computer Science program). Since I'm a transfer student, I get the last pick of leftover classes not already taken. Emphasis on 'last pick' and 'leftover'. It's highly probable that whatever classes I intend on picking tomorrow, I might not even get because other students ...

Looking for a better JavaScript unit test tool

Let's consider the state of JavaScript unit tests and testing tools. JsUnit We already use it for some of our js code. Pros can be invoked from an ant build file launches browser to run the tests Eclipse plug-in Cons launches browser to run the tests Does not support js file to write the unit test code: it has to be embedded inside...

Can you render arbitrary HTML in each cell of a YUI datatable?

I want to add paginated table to a page. It should be 2 rows by 4 columns. Each cell contains a thumbnail image and some small links. We're using YUI elsewhere on the project, so I'd like to use the Datatable. All the examples I see are geared around tabular data (understandable), but my hunch is that I can rewrite the HTML of each...