dom

W3C dom api in Java, get child elements by name

I just realized that the method Element.getElementsByTagName("someTagName") returns a nodelist of all elements in the document that have a given tagname. What if I just want to get all child elements by tag name? For example... <person> <name>Bob</name> <car> <name>Toyota Corolla</name> </car> </person> ...

Javascript: find URLs in a document

how do I find URLs (i.e. www.domain.com) within a document, and put those within anchors: < a href="www.domain.com" >www.domain.com< /a > html: Hey dude, check out this link www.google.com and www.yahoo.com! javascript: (function(){var text = document.body.innerHTML;/*do replace regex => text*/})(); output: Hey dude, check out th...

[jQuery] Get width of element after resizing it

Hello, Is it possible to get the size of an element after resizing it using $(el).css()? My code is: function resize() { $(".combobox").css('width', '100%'); var width = $(".combobox").width(); } I've get the real value of the combobox only after calling the function a second time. The first time is gets the width before exe...

PHP Getting XPath of a DOMNode

I am creating an XML document on the fly. and I need to know the XPath of the Node I've just created. I don't see any such function like DOMNode::calculateXPath(void):string and I am not willing to write one by my own. is there any known lite 3rd party Solution ?? ...

Embed external website inside a page

I'd like to load something from website B into a page on website A and contain the functionality of website B within a container on website A. I tried doing this using a div and jQuery's load() method but I run into cross-domain-scripting issues (I think, it works with a local file but not a remote URL). I also tried using an iframe bu...

Modifying the contents of a HTML webpage on the fly in PHP

I would like to load a HTML document and modify it's text in PHP. For example, if I have a document like this: <html> <head><title>Test - Example.com</title></head> <body> <p><a href="http://www.example.com"&gt;Link number 1: Example.com</a></p> <p>Link number 2: Example.com - some random text</p> </body> </html> I would like to add a...

disallow selection inside an input element

I am looking to do the following Disallow text selection inside of an input element Do not show the cursor carrot inside of an input i cannot simply blur the input on click, focus must remain in the input. There is probably a way to do this in just IE, i would of course rather have a cross browser solution but ill settle for IE (or F...

remove xml nodes from xml document csharp

Hi, I have a XMLDocument like: <Folder name="test"> <Folder name="test2"> <File>TestFile</File> </Folder> </Folder> I want only the folder´s, not the files. So, how to delete / manipulate the XML Document in c# to delete / remove ALL elements in the document? Thanks! ...

Firing a Keyboard Event at the Body

I've done a lot of research on this but have come up empty handed. What I would like to do is invoke or create an event for the right arrow key (Key Code 39). I was planning on using an onclick event inside an tag to go to a function where this event could be 'fired'. Any help would be appreciated. If anyone needs context, I have a jQu...

Syntax Error with John Resig's Micro Templating after changing template tags <# {% {{ etc..

I'm having a bit of trouble with John Resig's Micro templating. Can anyone help me with why it isn't working? This is the template <script type="text/html" id="row_tmpl"> test content {%=id%} {%=name%} </script> And the modified section of the engine str .replace(/[\r\t\n]/g, " ") .split("{%").join("\t") .replace(...

Is there a way to get all valid keywords for CSS property?

Round two. First was "How do I get all supported CSS properties in WebKit?". I'm looking for magic CSSkeywords function: CSSkeywords('float') --> ['left', 'right', 'none'] CSSkeywords('width') --> ['auto'] CSSkeywords('background') --> [ ["repeat", "repeat-x", "repeat-y", "no-repeat"], ["scroll", "fixed"], ["top", "center", "bo...

Dynamically inserting an image with JavaScript does not work on images that 302 redirect

I am dynamically inserting an image into an HTML document using jQuery. Here is the code: var image_url = "http://www.kottke.org/plus/misc/images/castro-pitching.jpg"; var $image = $('<img src="'+image_url+'" width="50" height="50" />'); $('body').prepend($image); Notice that the image http://www.kottke.org/plus/misc/images/castro-pit...

How to access CSS generated content with JavaScript

I generate the numbering of my headers and figures with CSS's counter and content properties: img.figure:after { counter-increment: figure; content: "Fig. " counter(section) "." counter(figure); } This (appropriate browser assumed) gives a nice labelling "Fig. 1.1", "Fig. 1.2" and so on following any image. Question: How can I ac...

.before method adds unexpected close tags

I have a table in my markup on which I want to add some divs before and efter like this: <div class="widebox"> <div class="widebox-header">Opret/rediger bruger</div> <div class="widebox-middle"> <table id="Table3"></table> </div> <div class="widebox-bottom"></div> </div> I'm trying to do this with jQuery, like this: $('#Table3').befo...

how to figure out if the present node is the last child of the parent's node

Hello, I'm trying to figure out how to know if a node is the last child of another, or not. I know how to retrieve the parent's lastChild name ($node->parentNode->lastChild->nodeName), but as sometimes there's many same node names within the same parent, the name is definitly not the way to find the last child. I'm looking for some kin...

Node removal and event handlers

Just interesting... What happens to node's event handlers when I remove it completely from the DOM tree? That means, if I create a node with the same id as removed node later, will it have the same event handlers? ...

innerText/textContent vs. retrieving each text node

I've heard that using el.innerText||el.textContent can yield unreliable results, and that's why I've always insisted on using the following function in the past: function getText(node) { if (node.nodeType === 3) { return node.data; } var txt = ''; if (node = node.firstChild) do { txt += getText(node); ...

Jquery-Different between event.target and this keyword?

What is the different between event.target and this? let's say I have $("test").click(function(e) { $thisEventOb = e.target; $this = this; alert($thisEventObj); alert($this); }); I know the alert will pop different value. Anyone could explain the difference? Thanks a million. ...

JQUERY gotcha, Why can't I change inside an iframe that is hosted locally?

Give the following on a page: <iframe frameborder="0" allowtransparency="true" tabindex="0" src="" title="Rich text editor" style="width: 100%; height: 100%;" id="hi-world"> <p><span class="tipoff" title="System tooltip for search engines">Download now</span></p><p>adasdads</p><p>a</p><p><span class="tipoff" title="System tooltip for se...

Insert a Script into a iFrame's Header, without clearing out the body of the iFrame

Hello, I'm looking to add a script to an iFrame's header while not losing everything contained in the iFrame's body or header... here is what I have right now which does update the iFrame with the new script, but it cleans everything in the iframe out, not appends which is what I'd like. thxs! B // Find the iFrame var iframe =...