dom

Weird mapping of DOM elements into variables

Today a workmate was working on a third-party video player integration for a set-top-box and found in their documentation an example like this: <a id="say_hello">Hello</a> <script type="text/javascript"> say_hello.onclick = function() { alert("Hello world") } </script> I just suspected it was something related only with CE-HTML but...

I want to extract the contents of a node as a string using XPath and PHP

Hi, I have a function that accepts a general HTML file and a general XPath expression. I want to extract a string of the matched node containing the entire text including HTML tags. Here's a simplified example... <?php $inDocStg = " <html><body> <div>The best-laid<br> schemes o' <span>mice</span> an' men <img src='./mous...

libxml2 from java

Hi, This question is somewhat related to http://stackoverflow.com/questions/530064/fastest-xml-parser-for-small-simple-documents-in-java but with a few more specifics. I'm working on an application which needs to parse many (10s of millions), small (approx. 300k) xml documents. The current implementation is using xerces-j and it takes...

jQuery to get next match in the DOM after a particular element

I hate to admit it but I'm stuck trying to figure out how to do this. e.g. pretending you have the following structure: <div> ... <div> <ul> <li> <a href="..."><img class="foo"/></a><!-- "previous" --> </li> <li> <a href="..."><img class="bar"/></a> </li> <li> <a href="...">...

How do I create a documentFragment in GWT?

Creating a document fragment using plain Javascript is dead simple: var docFragment = document.createDocumentFragment();. However, in GWT, this does not appear to be available, though there is a DocumentFragment interface in package com.google.gwt.xml.client that does not appear to be applicable. Does anyone know of a way, either using ...

Cross browser HTML5 iFrame

Right now I have an iFrame object with the seamless attribute which looks perfect, <iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.google.com%2F&amp;amp;layout=standard&amp;amp;show_faces=false&amp;amp;width=400&amp;amp;action=like&amp;amp;colorscheme=light&amp;amp;height=35" seamless></iframe> with a coupl...

How do I set up an if/or condition, such that my design changes based on the user's browser's font size?

Answerers: How does one literally detect the user's font scale, so that it may be used as a variable? I am trying to create some if/else statements based on the user's font scaling (not browser zooming), to extend the usability of my sites. The two given answers are workarounds for a single case (the scenario described). The scenario ...

calling a function in javascript after a period of time has passed

I'm trying to write a function that will auto suggest what the user means when they type into an input field. Right now I have all of the auto suggest code complete but in my javascript I can't get to the first if in toggleGenusInput no matter what I do (this first if queries the database through php and gets the suggestions). Does anyo...

Appending tr to tbody using YUI

I know this can be done easily using jQuery but haven't been able to find out how to accomplish it with YUI 2. I am submitting a form via AJAX and in the callback, on success, I want to add the information that was inserted into the existing table in the DOM. This is what I am trying with no success: var callback = { success: func...

Toggling span tag on and off with JQuery

Hey guys, I'm trying to toggle the contents of a span tag on and off using a jquery function. I'm using a span tag as I want the contents to be inline with the rest of the data on the line when it gets toggled. On page load the image I want to toggle appears inline and in the correct position, however upon toggling the image re appear...

How to select this via jQuery (include text in selector)?

What is a safe and reliable way to select the link below? I am having trouble to ensure I include the "Select" text in the selector to ensure I do not select another link: <span class="pickerWrapper">....<a href="...">Select</a></span> ...

Strange behavior when applying Array.prototype.slice method to result of querySelectorAll

I'am trying to use jquery's selectors as custom Selenium locate strategy. Exactly as in this article http://johnjianfang.blogspot.com/2009/04/how-to-use-jquery-to-create-custom.html Unfortunatly when I use selenium.click('jquery=a.mylink') method nothing happens. But selenium.click('css=a.mylink') still works perfectly. I did a little...

How does JavaScript interpret indexing?

function highlightRow(searchRow) { if(searchRow != null) { var oRows = document.getElementById('Table').getElementsByTagName('tr'); //use row number to highlight the correct HTML row. var lastTwo = searchRow; lastTwo = lastTwo.slice(-2); //extract last two digits ...

Without using document.write how can I insert a DOM node where the current JS is executing?

<body> <div id="outer"> <script>var e = document.createElement("div"); e.id = "inner1"; document.body.appendChild(e);</script> <script>document.write("<div id='inner2'></div>");</script> The structure I want would be: html>body>div#outer>div#inner1+div#inner2 the structure I get is: html>body>(div#out...

Handling images from XMLHttpRequest (with HTML and Javascript)

I am using an XMLHttpRequest to fetch an image from a server (run locally from a third party server-applet) A simplified version of the code is shown below. The image is returned as a JPEG and the returned header shows "content-type= image/jpg". I can view the information via Firebug for Firefox. However I am having a terrible time...

how to parse a HTML page with PHP5 and DOM?

hi there! i'm working on some piece of code that should get the contents of a very specific html-tag of an html-document given. $html = "<html>..........truncated.........<div>blablabla<br />xy</div>....."; $dom = new DomDocument(); $dom->loadHTML($html); $divs = $dom->getElementsByTagName('div'); echo $divs->item(0)->nodeValue.'<br>...

Is that possible to do this using jQuery ?

I have a structure of divs inside divs, something like this: <div class='parent'> <div class='a first'>something here</div> <div class='a'>something here</div> <div class='a last'>something here</div> <div>something here</div> <div>something here</div> <div class='a first'>something here</div> <div class='a'>...

Append Style to DOM not Replacing Existing

How can I append style element to DOM without eliminating existing style on the item (eg color, text-align, etc). The event calls the function, but the problem is 'Style' gets completely replaced with the single item instead. I have simple code triggered on event: function changeback(onoff) { if(onoff){ docum...

Siblings with dom/xpath

Hi, Have been trying several days to parse the following html code (notice that there is not a real hierarchal tree structure). Everything is pretty much on the same level. <p><span class='one'>week number</span></p> <p><span class='two'>day of the week</span></p> <table class='spreadsheet'> table data </table> <p><span class='two'>a...

optimize dom-heavy JS sorting

Hi guys, So I've built this mail-program-like HTML viewer (no real emails, just some messages from user to user). It basically behaves just like windows explorer, where you have the labels at the top and the files you can sort by date or alphabetically. Each message looks like this: <div class="mail_msg" d_id="363"> <div class="don...