dom

Javascript memory leak/ performance issue?

I just cannot for the life of me figure out this memory leak in Internet Explorer. insertTags simple takes string str and places each word within start and end tags for HTML (usually anchor tags). transliterate is for arabic numbers, and replaces normal numbers 0-9 with a &#..n; XML identity for their arabic counterparts. fragment = d...

Which method should be used ideally - document.getElementById or document.forms[]?

Hi Guys, I would like to know which of the following method is better? document.getElementById or documennt.forms[]? Which is the one that cshould be used regularly. The focus is on performance. Regards, Naveen ...

How to swap HTML elements in javascript?

I am using classic Javascript for DOM scripting, i have a set of DIV's in a container DIV. On click event of child DIV's, i want that the child DIV which has caused event to be swaped with the DIV above it.. my code goes here.. <div id="container"> <div onclick="swapDiv(event);">1</div> <div onclick="swapDiv(event);">2<...

Finding and Printing all Links within a DIV

Hello all, I am trying to find all links in a div and then printing those links. I am using the Simple HTML Dom to parse the HTML file. Here is what I have so far, please read the inline comments and let me know where I am going wrong. include('simple_html_dom.php'); $html = file_get_html('tester.html'); $articles = array(); //fi...

Advantages of createElement over innerHTML?

In practice, what are the advantages of using createElement over innerHTML? I am asking because I'm convinced that using innerHTML is more efficient in terms of performance and code readability/maintainability but my teammates have settled on using createElement as the coding approach. I just wanna understand how createElement can be mor...

What's the most concise cross-browser way to access an <iframe> element's window and document?

I'm trying to figure out the best way to access an <iframe> element's window and document properties from a parent page. The <iframe> may be created via JavaScript or accessed via a reference stored in an object property or a variable, so, if I understand correctly, that rules out the use of document.frames. I've seen this done a number...

mootools get data of child element of li?

Hi there, I am trying to get some information of a child element of an li using mootools, essentially my html looks like this, <li><a href="/home" id="home" class="nav-link">Home</a></li> I am wanting to be able get the id, class and href of the a tag using mootools, so far my javascript looks similar to this, $$('.rate').each(f...

Is event.preventDefault cancelling change events?

Hello! I have a certain situation I want to clarify for myself, and I would be glad if anyone has any experience with this issue and is willing to explain it to me. I have a textarea that has a change event handler: textarea.bind('change', function(event){ // do something }); Hypothetically, what if I have some sort of a click ev...

Using Simple HTML Dom to match a string on the page

Hello all, How do I match and get the flash vars on a HTML page? I am using simple HTML dom element and I am able to narrow down to a div containing the text I need. <script type="text/javascript"> var s1 = new SWFObject("jw4.4/player.swf", "player", "400", "50", "9"); s1.addParam("allowfullscreen", "true"); s1.addParam('allowscriptac...

assigning variables to DOM event listeners when iterating

I'm thinking there's some basic stuff that I'm missing here; for (var i=1; i<=5; i++) { var o = $('#asd'+i); o.mouseover(function() { console.info(i); }); } When hovering over the five different elements, I always get out the last value from iteration; the value 5. What I want is different values depending of which element ...

JavaScript: get the current executing <script> node?

Hi, I need to know if it is possible the current execution node? Example: ..html <script id="x"> console.log(document.currentNode.id); // << this must return "x" </script> ..html Thanks! ...

How to retrieve the content of <script src="myscript.ms"></script>

if it was inline instead of src it would be easy to use innerHTML however it returns blank...so i assume the src attribute makes the content of myscript.ms not go into the dom as it normally does for inline script. How can I access the data in myscript.ms file short of using some internal browser extension method? Thanks. ...

Change XML node element value in PHP and save file.

<testimonials> <testimonial id="4c050652f0c3e"> <nimi>John</nimi> <email>[email protected]</email> <text>Some text</text> <active>1</active> </testimonial> <testimonial id="4c05085e1cd4f"> <name>ats</name> <email>[email protected]</email> <text>Great site!</text> <act...

Performing an action on Parent/Child elements independently.

I have HTML similar to the following in my page <div id="someDiv"> <img src="foo.gif" class="someImg" /> </div> The wrapper div is set up such that when it is clicked, it's background-color changes using the following jQuery code. $("div").click(function(event){ $(this).css("background-color", "blue"); }); I also have some ...

How to get elements from a page using Simple HTML DOM Parser

Hi I am trying to parse a HTML page using the Simple HTML DOM Parser. This HTML page doesn't make use of IDs which makes it harder to refer to elements. On this page I am trying to get the Album name, Song title, download link and the album image. I have done this but I can't even get the Album names! $html = file_get_html('http:/...

Controlling the scope of a document.write call coming from a third party

Dear all, I'm writing a webpage that relies on an external javascript file (that I have no control of), which returns data by using document.write's. Is there any way to dynamically call the function without it overwriting the whole document? Here's the most concise code I can think of: <html> <head> <script type="text/javascript">...

DOMNode reference doesn't work anymore after appending it to another element twice

Hi, I'm using the a wrapper around the PHP5-class DOMDocument to generate my HTML. This makes it easy to modify the HTML by using the DOM. An example is creating element #1 and adding it to the element #2 and still be able to modify element #1 directly. A problem arises however with the following: Element #1 is added to element #2 El...

Selecting a link with jQuery

I want to be able to search for a substring inside the href's in the below code and select the link AFTER the selected string. So, for example the string "page=2" would access the third link. Thanks in advance. <div id="container"> <a href='test.php?page=1&title=a title'><a title</a> <a href='test.php?page=2&title=another title'><anoth...

Adding new elements into DOM using JavaScript (appendChild)

I sometimes need to add elements (such as a new link and image) to an existing HTML page, but I only have access to a small portion of the page far from where I need to insert elements. I want to use DOM based JavaScript techniques, and I must avoid using document.write(). Thus far, I've been using something like this: // Create new ...

How to save webpage in QT webkit as "save as complete webpage"

Hello, I need to save web page using QT webkit similar to "Save as complete webpage". Following are my requirements, Save the index html file, maintaining entity encoding. Need to download all linked images and other resources. Need to change resource path in html page to local downloaded path. Need to maintain webpage current stat...