dom

What do the FireBug DOM colors mean?

I'm confused with these colors. I noticed there are 4 colors showing in the left hand column of FireBug DOM tree: Bold black Black Bold green Green In the right hand column: Blue Red Bold green Green Multiple color elements representing object structures. What do this colors represent? And why, e.g, I can access window.document.U...

Is it possible to take a crawled html file, and get information about how a browser would render it?

Examples of stuff I'd like to do: - process javascript and produce new DOM - be able to provide information about DOM objects as rendered (e.g. position, size) Edit: My main concern is if a page contains a large, central flash object (typically a movie or game). ...

Regular Expression to find URLs in block of Text (Javascript)

I need a Javascript regular expression that scans a block of plain text and returns the text with the URLs as links. This is what i have: findLinks: function(s) { var hlink = /\s(ht|f)tp:\/\/([^ \,\;\:\!\)\(\"\'\\f\n\r\t\v])+/g; return (s.replace(hlink, function($0, $1, $2) { s = $0.substring(1, $0.le...

adding form elements with javascript - they won't submit

This is similar to the problem here: .../questions/1386228/add-form-element-dynamically-using-javascript-not-submitting but I don't know what his answer was besides rewriting from scratch. Here's my problem: Form elements added dynamically to the page do not appear in the $_POST array. I'm doing this same method several other instances...

PHP DOMDocument error handling

Hi, In my application I am loading xml from url in order to parse it. But sometimes this url may not be valid. In this case I need to handle errors. I have the following code: $xdoc = new DOMDocument(); try{ $xdoc->load($url); // This line causes Warning: DOMDocument::load(...) // [domdocument.load]: failed to op...

DOMElement cloning and appending: 'Wrong Document Error'

There's something I don't fully understand about node cloning with the PHP's DOM api. Here's a sample file that quickly duplicates the issue I'm coming across. $doc = new DOMDocument( '1.0', 'UTF-8' ); $root = $doc->createElement( 'root' ); // This doesn't work either $root = new DOMElement( 'root' ); $doc->appendChild( $root ); $doc...

Prototype Ajax.Request only calling the last callback

Hi all, I'm writing a userscript for a website that uses Prototype. Rather than use the GM libs (mainly so I can easily repurpose it for Chrome), I decided to use the already-loaded Prototype functions. I'm iterating through the rows of a table, each signifying a unique user, by checking for an online status element on their profile pa...

Override default behaviour for link ('a') objects in Javascript

Hi, I don't know if what I'm trying to accomplish is possible at all. I would like to override the default behaviour for all the anchor objects ('a' tag) for a given HTML page. I know I can loop through all the 'a' elements and dynamically add an 'onclick' call to each one of them from the body element 'onload' method, but I'm looking f...

Django ajax formatting convention

What's the correct way to do an ajax request, I've seen people using a returning render_to_string so that they can do all their formatting within python using the template language. eg~ return render_to_string('calendar.html', { 'self' : self, 'month' : self.today.month,}) with this as the javascript: $('#django_calendar_response').h...

How to get the HTML for a DOM element in javascript

Hi, Imagine I have the following HTML: <div><span><b>This is in bold</b></span></div> I want to get the HTML for the div, including the div itself. Element.innerHTML only returns: <span>...</span> Any ideas? Thanks ...

Tables created programmatically don't appear in WebBrowser control

I'm creating HTML dynamically in a WebBrowser control. Most elements seems to appear correctly, with the exception of a table. My code is: var doc = webBrowser1.Document; var body = webBrowser1.Document.Body; body.AppendChild(webBrowser1.Document.CreateElement("hr")); var div = doc.CreateElement("DIV"); var table = doc.CreateElement("...

PHP DOMDocument GetElementsByTagName Not Finding Elements

I have an HTML page containing alot of meta tags and I want to parse them to find certain ones. Here is the code I am using, but it's not picking up any of the tags. $dom = new DOMDocument(); $dom->preserveWhiteSpace = false; $dom->loadHtml($contents); $metaChildren = $dom->getElementsByTagName('meta'); var_dump...

Accessing the Firefox object model

Is it possible to access the DOM of a firefox page from a process outside of Firefox (in Windows.) It is possible to do with in IE via the accessibility interface and is a commonly used technique to access the IE browser without installing a BHO. But I was wondering if there is a similar technique available for Firefox, or must I install...

Can I get the location of where a JavaScript library is loaded from, from within the script?

Lets say I have a page with this code on it on www.foo.com: <script src="http://www.bar.com/script.js" /> Can I write code from within script.js that can check that it was served from bar.com? Obviously document.location.href would give me foo.com. Thanks! ...

jQuery: Easiest way to wrap an image tag with an A anchor tag

This is a simplified version of my problem. I have two buttons, and one image. The image code is something like this <img class="onoff" src="image.jpg"> When I press button one I want the image to be wrapped in an A tag, like <a href="link.html"> <img class="onoff" src="image.jpg"> </a> And when I press the other button, the A ta...

How to replace content of a popup window with an AJAX request?

I am at loss to understand how popup windows´ DOM-trees and their manipulation from opener window work. What is the proper way to implement what I am trying to do (described below)? I have one normal browser window where JavaScript function gathers selected elements and creates POST data string from them. I then open a popup window with...

Simple HTML DOM help

How can I extract the value attribute of an input tag? Using SIMPLE HTML DOM let me give you an example: <form action="#" method="post" name="test_form" id="test_form"> Name<input type="text" name="name" value="NaMe"/><br /> Address<input type="text" name="address" value="AdDrEsS"/><br /> <input type="hidden" value="sayantest" /> </fo...

Is there a way to parse html with lxml, but manipulate it with minidom?

I have an application where I've been using html5lib to liberally parse html. I use the minidom interface, because I need a real DOM API and ElementTree is not appropriate for what I'm doing. Here's how I do this: parser = html5lib.XHTMLParser(tree=html5lib.treebuilders.getTreeBuilder('dom')) parser.parse(html) However, parsing huge ...

How do I properly create and manipulate checkboxes via javascript in Internet Explorer?

Hello, I'm writing a web app. Based on certain choices the user selects, it dynamically creates a number of checkbox input elements. For the sake of usability, they should be created in a checked state, and the user would uncheck the ones they don't want. I have the code working fine in Firefox. Unfortunately, I have to target IE 7....

How to append DOM Element into an empty element in JavaScript?

I have bunch of objects that return a DOM-tree that I then use to append to an element. For example, var elem = document.createElement('div'); elem.appendChild(callSomePrototypesMethod()); elem.appendChild(callSomePrototypesMethod()); elem.appendChild(callSomePrototypesMethod()); and I will eventually end up in something like: <div> ...