javascript

Proper entity types for XHTML, XML and inside inline JavaScript

First, the way I understand it, it's more appropriate to use numeric entities in an XHTML document, such as " instead of ", is that right? Second, for my RSS XML feed, which entity type is correct? Named or numeric? I believe it's numeric, but see examples of both in my searches. Third, which of the following is correct for e...

Closure in Javascript

I have 100 elements with ids divNum0,...,divNum99. Each when clicked should call doTask with the right parameter. The code below unfortunately does not close i, and hence doTask is called with 100 for all the elements. function doTask(x) {alert(x);} for (var i=0; i<100; ++i) { document.getElementById('divNum'+i).addEventListener('c...

Is it possible to get the size of a Flash video [YouTube] using JavaScript?

I would like to know the size of the movie I am watching on any video site [ if not possible on all video sites, then at least on YouTube ]. So is it possible, say I will specify the complete path like: 'http://www.youtube.com/watch?v=7xyuX7u-Xts' , to calculate the size of the Flash video (.flv) using JavaScript? Note *By saying size I...

changing content of a div with javascript and php include

Hello. I wish to do something iframe-like with my div i've got going here. Basically, i've gotten as far as making links change the content of the div like so: <a href="#self" onClick="document.getElementById('maincontent').innerHTML = '<?php include 'file.php'; ?>';">Open file</a> This works pretty well, sadly though, if i make ano...

jQuery loopedSlider problem

Hey. It seems the loopedSlider plugin only wants to show one div at a time. I sort of managed to show to slides at a time, but when I have 5 slides and I want to show 3 at a time in the container...it starts out fine...but slide nummer 5 is not showing to begin with. It's empty the first time the slider slides leaving a blank space. Then...

Why doesn't my AJAX script work?

I am trying to get the below code to call to a PHP file, and show the returned data. In Firefox, the alert shows blank, and in IE it shows sometimes but mostly nothing. The PHP script is a simple echo "hello";. The script function make_request() { try { // Firefox, Opera 8.0+, Safari httpxml=new XMLHttpRequest(); } catc...

In javascript, how can I tell what object a function is bound to (ie, its 'this') without calling it?

Does anybody know? Couldn't find this question asked before, even though it seems fairly basic. ...

How do I talk to Firebug from a Web Worker?

My web workers are becoming increasingly complicated and I'm sorely missing Firebug access while working with them. This: console.log("test"); Does not produce anything from a web worker. I've also tried the following: dump("test"); And that doesn't produce any output either. Firefox version: Mozilla/5.0 (Macintosh; U; Intel Mac...

Why isn't the jQuery Color Picker Plug-in working for me in Firefox?

I am trying to attach a JQuery color picker plug-in to a textbox. The same code works in IE 6 & 7 but does not in FireFox. I see no errors or warnings of any sort it feels as if the plugin code is just being ignored. <script src="/colorpicker.js" type="text/javascript"></script> <script type="text/jscript"> jQuery(function...

javascript if drop down selected then set value of text box

Hi I've spent some time searching around for this, but can't seem to get it all worked out. I have a shipping drop down and I want to split off the type of shipping and the amount selected and put them into two separate hidden fields. (I am using text fields at the moment for easier testing) For example- if they choose from the first ...

How might I simulate a backspace action in a text field?

When a button is pressed, I simply want to simulate a "backspace" in a regular text box, deleting the character to the left of the cursor. Google and various forums are producing really random results on this. What's the proper way to do this? ...

Stop the browser “throbber of doom” while loading comet/server push XMLHttpRequest

(This question is similar to this one, but it's for using XMLHttpRequest instead of an iframe for Comet.) I'm starting an async long poll like this: var xhr = new XMLHttpRequest(); xhr.open('POST', url); xhr.send(); If I do this inside <script>...</script> in the head, it will cause the document to keep loading forever. (I'm testing ...

Embedding C# code using <%= code %> within javascript <script> tags

Hi All, I'm using ASP.NET MVC and would like to get Model information for use within my javascript. I've strongly typed the view, and thus am able to use <%= Model.Name %> within my HTML to get Model data. But once I'm in the <script> tags, I get no intellisense (in Visual Studio) when using <%, and the information doesn't seem to be r...

Manually Caching SWF/SWC in the Browser - Mimic Adobe's Signed SWZ?

Hey, I would like to take advantage of Adobe's Runtime Shared Library system for swc's, but I'm not sure how it ACTUALLY works, like the programming behind it. I understand that it allows you to load SWCs at runtime, but how does it do that? I'm asking because I would like to try to mimic something like the Signed RSL "swz" system Ado...

37 Signals Style Lightbox | How to do this?

Does anyone know how 37 Signals built the pop ups for image previews that are now in basecamp? I really like how quickly they load and the fact that the whole page doesn't get "light-boxed" and there is a minimal border It's very snappy. You can see this effect on the marketing page for campfire: http://campfirenow.com/?source=37signals...

How do I best prioritize HTTP requests on a web page?

I need to prioritize the downloading of (in my case) images. To do this I would prefer to use some kind of plugin (preferably for jQuery) that lets me do this without having to build my own downloadqueue mechanism. Consider this scenario: You have a web page. Your web page is able to show a given user three images. These images are on...

beginner javascript question

Hi, This should be easy, but since I'm new to programming, specially in javascript, I cannot figure it out. Let's say I have the following javascript code: var InjectClientValue = Class.create(); InjectClientValue.prototype = { initialize: function( sourceElement, eventElement, updateElement ) { this.sourceElement = $(sourceElem...

Changin a div border with javascript.

I have created a div programaticaly using. var Element; Element = document.createElement('div'); Now I want to change the right and bottom border to "#CCCCCC 1px solid". I don't want to use a library for this and using CSS classes is not possible. ...

Make images load when they enter visible section of browser?

I was browsing around the web and I saw something I've never seen before. on this site: http://blogof.francescomugnai.com/2009/04/mega-roundup-of-geektool-scripts-inspiration-gallery/ When you navigate down the page, the images only load when they are in the visible portion of the browser. I have never seen this before and was wondering...

How do I select arbitrary text on the page using javascript?

Let's say I have a contentEditable div, to the user can edit and change the text and elements inside it. How do I arbitrarily change the selection in this div with javascript? By "change" I don't mean "change the contents of whatever the user has selected", I mean actually change what is selected. The user should then be able to type ove...