dom

Javascript style display not working

function insert() { var linkElement = document.getElementById("BackButton"); var linkElementLnk = document.getElementById("BackButtonlnk"); var loc_array = document.location.href.split('/'); if (loc_array[loc_array.length-3] == "m") { linkElementLink.style.display = 'none'; } else if (loc_array[loc_ar...

What happended to DOM level 1?

So, what happened to the DOM level 1? For example there are DOM level 0 events like this window.onload = func; element.onclick = func; and there's DOM level 2 (and now even level 3) events element.addEventListener("click", func, false); But no mention anywhere about DOM level 1 events? Was it like with Lesuire suit Larry 4 that g...

How to zoom content of a web page?

How to zoom content of a web page? Like for example on familyecho.com you can zoom in and zoom out. How do they do it? ...

Add text after element that contains string.

I want to write an extension for Google chrome that detects snippets of source code on web pages and automatically copies them to the clipboard. I'm new to javascript and jquery, so for the first step, I wanted to try a very simple case. Using this site as an example: http://www.swharden.com/blog/2010-03-05-realtime-fft-graph-of-audio-...

Will removing an iframe from the DOM always stop an upload POSTed from that iframe?

I'm doing some async file uploading with iframes, and I'm wondering if simply pruning the iframe from the DOM is enough to cancel an upload. This discussion seems to imply that this a poor approach to the problem overall, but annoyingly the JS `expert' refuses to reveal his solution. Anyway, removing the iframe works in Gecko + WebKit,...

What is the jQuery equivalent to these javascript DOM objects/methods?

I am trying to figure out what would be the jQuery equivalent to the following code: var temp = $('#logoutFrame2').contents().find('html').html(); try { var temp1 = document .getElementById('logoutFrame2') .contentWindow .document .getElementById('theCBO...

How do I remove an element from the DOM, given its id?

In this specific case, the element is a table row. ...

Is if(document.getElementById('something')!=null) identical to if(document.getElementById('something'))?

When I want to check if an element exists in a page. Are these 2 checks the same? Is there a better more compact way to check the existence. What if I want to check if the value==''. Can this be included in this check as well somehow. ...

How can I insert element into xml after/before certain element in java

Here is my code, maybe you will notice right away what I'm missing : DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = domFactory.newDocumentBuilder(); Document doc = builder.parse(fileName)); XPathFactory fact...

document.createElement("script") synchronously

Is it possible to call in a .js file synchronously and then use it immediately afterward? <script type="text/javascript"> var head = document.getElementsByTagName('head').item(0); var script = document.createElement('script'); script.setAttribute('type', 'text/javascript'); script.setAttribute('src', 'http://mysite/my.js...

Insert a script into the DOM that calls AJAX

We have a tool that allows people to add code to a dynamic page. A bit of code (a widget) needs to be injected into the DOM, not hard coded into the html. I use jquery to do it. The problem is that it ends up redirecting the page... I need to solve this. Here is an example. Create a page with the following: <script type="text/javascr...

Code not working as expected

Hey guys, I think I need a new set of eyes to help me look at my code which isn't working as what I've expected. Sorry for the relative ease of the question but I don't really code in Javascript. Anyways: Basically what I'm trying to do is to get the image to change to an inversed version on mouse over. So far I'm only testing the image...

How can you tell the difference between a generated and a selected element?

Is it possible, in either the jQuery API or the DOM, to check if an element exists on the page or not? Consider these two variables: var selected = $('span#mySpan'); var created = $('<span id="mySpan">Testing</span>'); Both will return a jQuery object containing a span element. Is there any way to tell that the first exists on the pa...

JS to update the window Location with a URL not a HASH

Hello, I'm building a web app for Sign In / Registration etc, and do not want the page to have to refresh. www.mysite.com I know how to set a hash on the URL without refreshing the page: location.hash to give: www.mysite.com/#signin But what I want: www.mysite.com/signin Without the hash so it's SEO friendly. Also, once I set tha...

Is there a way to find all elements matching a certain style using the DOM?

I want an array of all elements that have fixed position. This is what I've got so far (mootools code) $$('*').filter(function(aEl){ return aEl.getStyle('position')=='fixed' }); Is there a more direct way to do this? ...

force div to fill specified area?

what's the best way to force DIV to fill specified width? I have the following code that generates and assign width to DIV: function createLabel(str) { var textDiv = document.createElement('div'); textDiv.style.width = '200px'; textDiv.style.display = 'inline'; textDiv.appendChild(document.createTextNode(...

Extracting last character of a sentence using Regex

Hi, I want to extract last character of a string. In fact I should make clear with example. Following is the string from which i want to extract: <spara h-align="right" bgcolor="none" type="verse" id="1" pnum="1"> <line> <emphasis type="italic">Approaches to Teaching and Learning</emphasis> </line> </spara> In the ...

jQuery appending html versus appending existing element

Hello. I have a string big_html and I want to add it to some div. I have observed a performance difference in the following: $('#some-div').append( big_html ); // takes about 100 ms //create it first var append_objs = $(big_html); $('#some-div').append( append_objs ); //takes about 150 ms Does anyone know why this happens ? Thank you...

using jQuery to remove markup above and below <html> </html>

I have a website on a free domain that has html mark-up added server side to produce web banners. This mark-up is placed above and below the main outer tag. Is it possible to have jQuery strip this out prior to the page rendering? ...

How to properly unload/destroy a VIDEO element

I'm working on a realtime media browsing/playback application that uses <video> objects in the browser for playback, when available. I'm using a mix of straight javascript, and jQuery, My concern is specifically with memory. The application never reloads in the window, and the user can watch many videos, so memory management becomes ...