dom

PHP throws an error... sometimes, on a DOM Element [SOLVED]

Somewhere in my code I have: class aclass { ... function amethod() { $this->dom = $a_dom_document; $this->about = array('an_element' => $an_element_of_that_document); } ... } /* Somewhere else */ $instance->dom; // It's there, no problem. $instance->about['an_element']->parentNode->replaceChild($something_else, $this->...

jquery capturing text of selected id

If I have id's of the form: t_* where * could be any text, how do I capture the click event of these id's and be able to store the value of * into a variable for my use? ...

PHP's XPath returns too many elements

I'm trying to use XPath in PHP and I get too many elements. This is my code: libxml_use_internal_errors(true); $document = new DOMDocument; $document->strictErrorChecking = false; $document->loadHTML($text); $xpath = new DomXPath($document); $placeholders = $xpath->query('//div[starts-with(@class, "waf-ph-")]'); print '$placeholders->le...

finding location of HTML elements with javascript & offsettop

I'm trying to find the location of an element on the screen using javascript. This is what I'm doing. function locateTargets(){ var targets = document.getElementsByTagName("span"); for(var i = 0;i<targets.length;i++){ if(targets[i].className == "target"){ targetsY[targets[i].getAttribute("id")] = targets[i].o...

Is it a bad practice to reference Javascript objects from DOM elements?

As a "best practice" for front-end developers, is it bad to use the "control" property to reference back to the Javascript object? Here's a link to the property in question: https://developer.mozilla.org/en/XUL/Property/control I've seen a lot of Javascript functions that reference DOM elements using selectors and then perform DOM mani...

DOM event for browser password autofill?

I've got a fairly standard username/password entry box on a web site I'm building. The password box has a div containing "Password" overlaid on top of it, which is set to display: none; on focus or click. This works great until the user asks their browser to remember the password: in that case you can end up with the situation in the ...

Trapping click events on <a> elements that are programmatically added to a DOM

I have an AJAX callback that returns a list of results that are written out as links within a specific div. The code goes something like this: $.each(data, function (idx, item) { var a = document.createElement("a"); a.innerText = item.name; a.href = "#"; // TODO set handler for click event d.appendChild(a); d.in...

what would be the proper way to add multiple functions to the jquery $(window).load function declaration?

I am using the following javascript to animate two slideshows using the nivo slider object in jquery: <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script> <script src="jquery.nivo.slider.pack.js" type="text/javascript"></script> <script type="text/javascript"> $(window).l...

Removing wrapping HTML elements inside a RSS XML node

Hi All, I have a fetch function that injects rss content into a page for me. This returns an xml which contains the usual RSS elements like title, link, description but the problem is the returned description is a table with two tds which one contains an image the other the text. I am not sure how I can remove the table, img and the tds...

Selecting an option by its text

Hi, I'm developing a web page using django and I want to add some javascript to a form using jQuery. Basically I want to select an option in a form depending on an another selection. I need to use option's text and not option's values because option's values are generated dynamically by django. An extract of my code: javascript $...

Where can I find a copy of the wddx.dtd?

I have a project that involves parsing wddx webservice responses. The DOM DocumentBuilder is throwing an exception that the XML is malformed as it does not reference a dtd. I inserted a DOCTYPE statement and now it is throwing an exception malformed - cannot find the protocol. I am quite certain it is my reference to the DTD and I now...

Blinking document.title and IE7 (no way ?)

Hello, i develop a website and i need let the document title blinking when the browser lost the focus to get the attention from the user. This is a common task for example in some social network. Btw my javascript code work fine in Chrome, Firefox, Opera, but not in IE7 (that i am testing before release the site) IE7 have a strange be...

Identify HTML block elements in jQuery

I have simple one column HTML files (ebooks from Gutenberg Project). I want to identify in the DOM the block elements (like <h1> <p> <div> <table> etc, not <a> <em> <b> etc) and enclose them in <div> tags. Is there any easy way to do it in jQuery? Thanks ...

Close <p> tags in jQuery

I have a large html file of a story. The <p> tags are not closed, for example: <p> First paragraph <p> Second paragraph I would like to have a proper XHTML document: <p> First paragraph</p> <p> Second paragraph</p> Can I achieve this with jQuery? Thanks ...

jQuery over loaded ajax content

hello, I'm using fancybox plugin to show bigger images. if I put in the html page <a id="fancy" href='img_big.jpg'><img scr="img.jpg" /></a> it works fine, but if load with load() the same lines fancy box is not applied. how can i fix that? ...

Javascript Regex problem

I have <li> elements in my document such as: <li id="123" onMouseOver="foo();">Lorem Ipsum ... I would like to remove the attributes and get the string <li>Lorem Ipsum .... In order to do that, I use the replace() method: foo = document.getElementById('bar'); alert(foo.innerHTML.replace('<li(.*)', '<li>')); But it won't match and r...

Controlling textbox/overflow scrolling using javascript

I am trying to build a web console application at the moment. I have coded all the most major parts of the app, but I still need a way to display the text appropriately once I have brought it into the browser. There will be more text than the box should be displaying at any one time, so there obviously needs to be some sort of scroll. A ...

How can I access the plain text loaded in an <iframe> on IE?

I have an <iframe> whose src points to a plain text file (not HTML). The text gets loaded and displayed on screen, but seems to be hidden to JavaScript. In other browsers, iframe.contentWindow.document.body.innerText is enough to get it for you, but IE returns an empty string in that case. Is there a way that IE can access the text ins...

An elegant way to record the computed style for each DOM node to a file, for a large number of files?

Is there an elegant way to get the computed style for each DOM node in a web page, for a large number of files, in order to compare style data for similar nodes across those files? I'm working on a large number of HTML files (> 500) containing pretty broken HTML from MS FrontPage, trying to extract style data and convert it to semantic ...

Firing DOM mouse events programmatically from JavaScript

Is it possible to programmatically fire mouse events in DOM? My sample case would be the following: <html> <body> <iframe style="width: 500px; height: 500px;" src="something.html"></iframe> <div id="layer" style="position: absolute; left: 0px; top=0px; width=500px; height=500px;"></div> </body> </html> Whenever the user cl...