dom

Dynamically changing DOM-elements as they get's scrolled into view (performance)

I'm trying to find an efficient algorithm for dynamically loading background-images for a bunch of <li>'s, and are having some efficiency problems. My current code looks like this: function elementInView($elem, vps, vpe) { var elempos = $elem.position(); var pagestart = elempos.top + vps; var pageend = elempos.top + vps + $...

Script causes IE6 to fallover with no error

I hate IE6, in fact I wish microsoft would force out a patch that killed the damn thing stone dead. The following script works fine in IE > 6 & FF,WebKit(chrome etal) without issue; any ideas? (function getElementsByClass(searchClass) { node = document; tag = '*'; var els = node.getElementsByTagName(tag); ...

PHP encoding with DOMDocument

<tag> Алекс М </tag> When I try to get the content of the following code using DOMDocument functions, it returns something like: ÐÐ»ÐµÐºÑ Ðœ I've tried setting DOMDocument encoding to different values (UTF-8, ISO-8859-1), using mb_convert_encoding, iconv and utf8_encode but without success. How can I get "Алекс М" instead of "ÐлÐ...

DOMNodeInserted equivalent in IE?

Other than using a timer to count the number of elements over time and looking for changes, I can't think of a better way to simulate this event. Is there some sort of proprietary IE version of DOMNodeInserted? Thanks. ...

When I use javascript's document.write command it doesn't seem to display leading spaces. Help please.

This is the code I wrote up to display a Mancala board but it won't display the leading space for some reason. Does anyone know why this is happening? Any help is greatly appreciated. function display(board) { var space = " "; document.write(space); for (var i=0;i<board.length/2;i=i+1) ...

Select first sibling.

I'm trying to select the inner value of the first sibling - using jQuery - in an environment where I cannot alter the html markup. I have the following: <tr> <td>3</td> <td>bob</td> <td>smith</td> <td>[email protected]</td> <td> <img src="bobsmith.png" onclick="doSomething()" /> </td> </tr> I'm trying to...

Javascript-HTML - how to iterate through all the forms on a page?

How can I iterate through all forms in a document using javascript? ...

How to replace entire CSS of a page after an ajax request with jQuery?

I have a document with one CSS linked in. How can I replace the current CSS with one coming from a document that I just fetched with AJAX request using jQuery? Here's the code I am trying right now, but with no success so far: $(function() { $.get('next_page.html', function(data, textStatus) { $('link[rel=stylesheet]:first'...

Qt plugin + DOM access

Hi, I am writing a browser plugin with Qt. Im currently facing a problem of getting the dom object of the current page of the browser from my plugin. Any info/help on how to do this would be extremely appreciated. version: 4.6 browser: firefox/opera If it isnt possible to get it directly via Qt, how do i convert the NPObject that i get ...

Accessing input type="file" full path from a Java applet

It is possible to access HTML DOM from an applet using netscape.javascript JSObject API. However, if I query a value of a input type="file", on some browsers (Opera) I get a full path to a selected file, but on other browsers (Firefox, Chrome) just a file name without path. Is it possible, having an HTML input type="file", to figure out...

childNodes not working in Firefox and Chrome but working in IE

I have a gridview in its 3rd cell, there is textbox control, I am calling javascript function on onchange. Can some body tell me why this is not working in Firefox and Chrome but working in IE grd.rows[rowindex].cells[3].childNodes[0].value It return correct value in IE but not in Chrome and firefox (In FF and Chrome it return undefi...

How to call dynamically created flash external interface in IE from javascript?

What I have: A swf exports a function via ExternalInterface Javascript creates new embed object and adds it to the document Calling flash functions works fine in other browsers Calling flash functions will fail in IE 8 Example of exporting functions in swf: flash.external.ExternalInterface.addCallback("isActive", ... Example of c...

Javascript Large String storing in code vs. storing in a dom object (such as a <pre> , <div>)

I have a large javascript string. var s = '...............'; // this is about 32000 characters long. if you wonder: that bit of javascript is autogenerated. Does anybody know if it is better to store it outside of the javascript For instance in a dom object in the html page and then retrieve it (e.g. var s = document.getElementById(...

Problem displaying content added from parent window to child window in Firefox

Here is the code I am using to create and add content to a new window via JavaScript: var newWindow = window.open(); newWindow.document.title = "This is my new window"; newWindow.document.body.innerHTML = "<center>This is content added from the parent window</center>"; This works in every browser I have tested except ...

jquery mouseout of nested div question

I'm trying to fire a function on the mouseout of a div. However when you mousover an element in the div it fires the mouseout. <div id="my_div"> <div class="another_div">X</div> </div> <script> $("#my_div").mouseout(function () { alert('weeeee, I am out!'); } </script> This makes sense but how can I test for the mouseout eve...

Dropdwnlistbox using Javascript

I have dropdownlist box and two radiobuttons If i check first radiobutton, 1,2,3 vil be added to dropdownlistbox. If i select second radiobutton, 4, 5,6 will be added t dropdownlistbox. All these are created using java script.Here my problem is, Ididt select the drpdownlist values when i select any radiobutton Please help me ...

JavaScript: DOM text nodes

Take a look at the snippet below. Does it create a text node for the string "test" in the DOM? Can I select that node with jQuery for MooTools? <div id="foobar"> test <img /> </div> ...

JavaScript DOM references not holding up

For some reason ss.transition() does not affect the appropriate DOM elements after ss.goTo() is triggered by an onclick. The ss.transition() call under //Init does work as expected. I assume this is a scope problem. Little help? var ss = {}; ss.goTo = function(i) { ss.old = ss.current; ss.current = ss.slides[i]; ss.transiti...

Running javascript code after DOM has been updated from previous code

I'm pulling in a google news feed, then trying to take out some mal-formatting by accessing the newly-created DOM elements. var aryClassElements = document.getElementById('google-news').getElementsByTagName('div'); alert("Found "+aryClassElements.length+" divs in Google News"); But this alert shows 0. It hasn't found the newly-create...

How to go about late/lazy loading resources

Hi folks, I have a fairly long page (http://tiny.cc/JrSYr) with sections such as google maps, image slider, google ads, brightcove video (optional) and images. Loads nice and quick without JS and a little slower with JS. I've seen http://www.appelsiini.net/projects/lazyload and was wondering if anyone has used a similar approach or an...