Tag: dom

Can Javascript's “document” object be used as a variable?

I was wondering if I can add to Javascript’s document object. Like: var document = { name: “My Name” } Is that legal in JavaScript? If it is, is it considered “good practice”, or should I avoid it? If I define it as a variable, is it then considered as a unique object, and not […]

Javascript: 'window' is not defined

Well I’m trying to learn some javascript but this has been a pain. The following code has been giving me much trouble: window.onload = function () { for ( var i = 0; i < seats.length; i++) { for ( var j = 0; j < seats.length; j++) { document.getElementById(getSeatId(i, j)).onclick = function(evt) { getSeatStatus(getSeatId(i, […]

Comparing DOM objects in jQuery

I have looked through the other SO posts that seem to be of the same question but they are not. I have the following: <table> <tr id=”first_row”> <td><span id=”first_span”>item1</span></td> <td><span>item2</span></td> </tr> <tr id=”second_row”> <td><span>item1</span></td> <td><span>item2</span></td> </tr> </table> and jQuery(function() { var $a = $(“#first_row”); var $b = $(“#first_span”).parents(“tr”); var $c = $(“#second_row”); }); $a and […]

Get <table> element's nth <td> innerHTML dynamically

Is there anyway I can get the innerHTML of the designated nth <td> in a <table> using JavaSCript? Since my table is automatically generated, my <td>’s do not have IDs. I am using the following HTML code: <table id=”table”> <tr> <td onmouseover=”myTD()”>Cell 1</td> <td onmouseover=”myTD()”>Cell 2</td> <td onmouseover=”myTD()”>Cell 3</td </tr> <tr> <td onmouseover=”myTD()”>Cell 4</td> <td […]

How can I apply a jQuery function to all elements with the same ID?

I am new to jQuery. I have the following code: jQuery(document).ready(function() { jQuery(‘#carousel’).jcarousel(); }); It only applies to the first ul with id=”carousel”, not for the others. How can I apply it to all elements which have the same ID? HTML: <!– jQuery applies to this div –> <div id=”slideshow-carousel”> <ul id=”carousel” class=”jcarousel jcarousel-skin-tango”> <!– […]

Cortado Ogg-player in MediaElement.js – almost working

I made a few changes to the MEjs demo player, to enable playback of OGG in IE/Safari browsers, using the Cortado Java applet. I have play/pause working, and although getPlayPosition() isn’t getting the current position in milliseconds as described in the documentation, applet.currentTime and applet.duration work well for this purpose. I thought it would be […]

How to synchronously render components with React (or render to string)

For reasons too long to explain here (and not very relevant) I want to be able to circumvent React’s render batching and force a component tree to be immediately rendered in some DOM element, even if it means a forced layout and a slowdown of the application. I don’t need any listeners bound – I […]

Scrolling an HTML page with javascript?

I created a page that scrolled via JavaScript but in some browsers it does not scroll very smoothly when you and text to the page? And it doesn’t seem to work at all in chrome. My question is: What is the best method to create smooth scrolling html pages using JavaScript that works cross browser. […]

Javascript cannot unhide element after cloning?

I’m working on something where multiple functions will add various Event listeners to an initially hidden div, let’s just call it secretBlock. Only one will ever be active at any given point, but all said functions will manipulate it by: First cloning sercetBlock to ensure no previous listeners are still attached Then setting the display […]

Appending inline javascript to a script tag

Possible Duplicate: How to append a line of JavaScript (rather than an exteral .js file)? I am trying to create script tag dynamically. I want to append the inline javascript to a script tag. My code var script = document.createElement(“script”) script.type = “text/javascript”; var scriptContents = ‘var isActive; window.onfocus = function () { isActive = […]