dom

how to determine if the browser supports selectionStart if there is no text selected

This code will return true if the browser supports selectionStart and some text is selected, but if no text is selected it returns false (even on browsers that support it): if (el.selectionStart) { } How do you determine if the property is available regardless of whether text happens to be selected? Thanks ...

How to make a new document from a subset of another document?

Let's say we have an org.w3c.dom.Document representing the following XML: <Fruits> <Apples> <Red/> <Green/> </Apples> </Fruits> If we know that the document always will contain a <Fruits> root with only one child (in this case <Apples>, but the name of the child is generally unknown), how can we make that child the root of...

How to handle Android trackball events from a web page?

Is there any DOM event in Webkit associated to trackball events (movement and pressing)? Or is there any other way to handle those events from a webpage? ...

how to Delete parent Node of XML by checking the Value of it in PHP DOM

I have an XML Like below <Row><Cell ss:StyleID="s245"><Data ss:Type="String">ABSOLUTE</Data></Cell> <Cell ><Data ss:Type="String">Yellow</Data></Cell> <Cell ><Data ss:Type="String">Exist</Data></Cell> <Cell ><Data ss:Type="Number">30</Data></Cell> <Cell ss:StyleID="s258"/> </Row> <Row><Cell ss:StyleID="s229"><Data ss:Type="String">PAR...

How can I add an (otherwise) invalid HTML element into TinyMCE.

My HTML contains elements like this, because it uses inlines from django-basic-apps. <inline type="myapp.mymodel" id="4" /> I'm trying to use tinymce to insert one of these into the DOM. On the frontend of the site, these are processed into good code. In tinyMCE I've added the config: extend_valid_elements: 'inline[id|ids|type|filte...

What's the point of the Anti-Cross-Domain policy?

Why did the creators of the HTML DOM and/or Javascript decide to disallow cross-domain requests? I can see some very small security benefits of disallowing it but in the long run it seems to be an attempt at making Javascript injection attacks have less power. That is all moot anyway with JSONP, it just means that the javascript code is...

Need help creating dynamic Javascript Arrays

Part One: I'm trying to figure out how to use the DOM and Javascript to create an array containing the links in multiple lists. The problem is I need each UL to have a unique array containing the links; the only unique ID I am able to use in this case is the name value in the link tags. I will not be able to add anything else to the mark...

Loading elements into the DOM with jQuery.

Hello everybody, I have a quick question that I'm sure some of you would have an answer for, let me explain. I'm working on a very simple website, static content, pure HTML, and CSS, and some javascript to make everybody's life easier. The site has a header, nav, side bar and footer and although the site is static, I thought I could use ...

How do I get the Id of a hyperlink?

How do I get the id of a hyerlink on a page? Example <a id="myID123" href="myLinkPageName.aspx">myLink</a> Note: The page name and the link name is static! I should get the id "myID123". ...

performance test of DOM operations via innerHTML

According to spirit of stackoverflow (thanks to @Bill the Lizard clarifying this) I would like to introduce small own research of the well known to all front-end web developers question. How to get better performance of jscript while programming DHTML, using innerHTML or DOM operations? For the testing I have created single HTML page ...

Get element content from a variable containing html

How do I use the DOM parser to extract the content of a html element in a variable. More exactly: I have a form where user inputs html in a text area. I want to extract the content of the first paragraph. I know there are many tutorials on this, but could not find any on extracting from variable and not a file(page) Thanks ...

jQuery Clone Performance

I've read that javascript gets significant performance benefits from modifying off-dom. Earlier today, I was reading the clone documentation: "Note that when using the .clone() method, we can modify the cloned elements or their contents before (re-)inserting them into the document." Is the implication then that if I have 1,...

Equivalent of "parentNode" in internet explorer

I wrote some code that modifies the images on a webpage. Works with firefox and safari. But tryingto get it to work with Internet explorer has got me stumped. What is the equivalent of "parentNode" in explorer? Or how does one trick it into working? images = document.getElementsByTagName('img') parms = {}; for (a=0;a < images.lengt...

How to get selected textnode in contentEditable div in IE?

I am attempting to create a simple texteditor with HTML5 contenteditable on a div tag. As you know, selected text is handled quite differently in IE. this.retrieveAnchorNode = function() { var anchorNode; if (document.selection) anchorNode = document.selection.createRange().parentElement(); else if (docume...

correct this xpath expression please

This is a piece of my XML document: <?xml version="1.0" encoding="UTF-8"?> <catalog> <mfVictor> <decal> <company>Victor</company> <title>Wood Horn with Blue Background</title> <image> <url>victor01.jpg</url> <width>60</width> <height>60</height> <name>Wood Horn Blue Background</name> <link></li...

iframe location in javascript

In this example, alert is blank; I want to read the location of iFrame, I am using object.src for this but it work only if I set its src attribute. But I set iFrame's location using window.open method and in this case it is not working. What I do ? <body> <iframe id="location" name="address" style="width:700px; height:700px;"> </i...

DOM based scripting.

ok so here's my problem... i've been following this tutorial ( http://www.alistapart.com/articles/dropdowns ) to make a css drop down menu with my wordpress blog. everything works fine... except in IE6. now i know this is normal, and in the link i posted above there is a fix of this which makes use of DOM based scripting... is this java ...

What's a cross-browser way to check if a JavaScript variable is a <form> DOM object?

var form = document.createElement('form'); (form.isDOMForm()) would evaluate to true. ...

Supply data available via Jquery in .Net MVC 2

Hi. I am trying to create a partial view I call ImageViewer. It will be called supplying a list of image ids (simplified). I then want to return this partial view, something like imagecontroller.ImageViewer(new int[] { 5, 6, 7 }); yields the following: <div> <img grayuparrow /> <img source="image/getimage5" /> <img blackdownar...

Set <a> to display none

Here is my HTML: <td> <a class="link" href="#"> <span class="download">Link</span> </a> <a class="link" href="#"> <span class="csvdownload">Link 2</span> </a> </td> I need to set this CSS: a.link { display: none; } But only to the <a> that contains the span with the class csvdownload Ideally need to do this strict...