dom

Toggle row visibility one at a time

I have a couple of tables with similar structures like this: <table> <tbody> <tr>content</tr> <tr>content</tr> <tr>content</tr> <tr>content</tr> <tr>content</tr> <tr>content</tr> <tr>content</tr> <tr>content</tr> ..etc --- The fake button is added here <div class="addrow">Add another</div> </tbody> </table> UPD...

javascript pausing consistently. How do I find what is causing it to pause?

I've got a fairly ajax heavy site and I'm trying to tune the performance. I have a function that runs between 20 & 200 times, depending on the user. I'm outputting the time the function takes to execute via console.time in firefox. The function takes about 4-6ms to complete. The strange thing is that on my larger test with 200 or ...

scrollTop value not reflecting actual position of div at beginning and end of scrollable distance

Hi folks, I am using jQuery's scrollTo to make relative adjustments in the position of content inside a div. Works fine: http://www.hmadvertising.com/test.php However I also want to show and hide the control elements when they aren't relevant. Eg no Up button when scrollTop is zero and no down when scrollTop == scrollHeight. The adj...

"Decompile" Javascript function? *ADVANCED*

[1] Ok, I don't even know how to call this, to be honest. So let me get some semi-pseudo code, to show what I'm trying to do. I'm using jquery to get an already existing script declared inside the page, inside a createDocument() element, from an AJAX call. GM_xmlhttprequest({ ... load:function(r){ var doc = document_from_string...

Determine which DOM elements the current text selection contains

I want to be able to find out which DOM elements are present in the text currently selected by the user in the browser. document.getSelection() would get us the currently selected text. But how can we determine which DOM elements are contained in this text selection? ...

Javascript incapable of getting element's max-height via element.style.maxHeight

I am making a simple accordion menu in javascript. I'd like to be able to set the compact and expanded heights for the elements via the css max-height and min-height values. For some reason, when I try to retrieve the min-height and max-height of the elements in javascript for animation purposes, I get an empty string rather than, for in...

JavaScript: How to get text from all descendents of an element, disregarding scripts?

My current project involves gathering text content from an element and all of its descendents, based on a provided selector. For example, when supplied the selector #content and run against this HTML: <div id="content"> <p>This is some text.</p> <script type="text/javascript"> var test = true; </script> <p>This is some more...

FancyBox, Obtaining an ATTR of the item clicked

I have the following lines of code: $("a.quickview").fancybox({ ajax : { type : "POST", data : 'itemID=' + $(this).attr("name") } }); Which is binding on: <a name="614" class="quickview" href="/URL/index.cfm">quick view</a> I want data to post as itemID=614, but $(this).attr("na...

HTML overlay height to cover entire visible page

I have a web page that loads some stuff using AJAX. I want to display an overlay with a loading indicator while the loading is in progress, so that the user cannot interact with most of the page - except the menu at the top. I'm using jQuery and the jQuery BlockUI plugin to do this. I call $(element).block() and it works fine, but the o...

TinyMCE editor dislikes being moved around

Hello guys, On a page I have, I need to move TinyMCE editors in the DOM tree once in a while. However, for some reason, the editor doesn't like it: it clears itself completely and becomes unusable. As far as I can see, this behavior is consistent between Safari 4 and Firefox 3.6, but not Internet Explorer 7/8. Here's an example. It tru...

Javascript DOM howto?

Hi, I am a javascript noob. I would like to select the second 'p' element of the div.box. How do I do this? Thanks a lot! Tom ...

How to get target element of keypress in designmode iframe

Is it possible to get the target element in a keypress event handler in a design mode iframe ? I know it can be done in the mousedown event handler (by accessing event.target), but in the keypress / keydown handlers event.target is always the iframe element. For example, with the following html, if the user types into the div where it sa...

HTML - Put SELECT tag content into INPUT type = "text"

Hi, I have a form in a webpage where I would like to put the selected item in a drop down list into a testbox. The code I have till now is the following: <form action = ""> <select name = "Cities"> <option value="----">--Select--</option> <option value="roma">Roma</option>...

document.getElementByID - checking whether an element has been found or not

Hi, guys. Here's a sample code, that opens an internet explorer window, navigates to google, and gets some element on the page by its unique id: set ie = CreateObject("InternetExplorer.Application") ie.navigate("www.google.com") ie.visible = true while ie.readystate <> 4 wscript.sleep 100 WEnd set some_object = ie.document.gete...

How do I get a useful value for height and width of a div element using javascript?

I need to be able to store the current height and width of a div at any point in time. Currently I am using div.style.height/width which works fine when the styling is applied inline. The problem is that this returns for example 600px and not 600. Is there a better way to do this? If not, whats the best way to get just the number 60...

Hide table rows if Cookie is there

Based on my previous question here and here, I found that I can set a cookie with javascript. I want to combine it with jquery to have a cookie state set for toggled table rows. I want to keep the hidden rows hidden upon reload. Here is what I have achieved so far: // Load cookies if any if(readCookie('togState')) { $('table#...

PHP XML Strategy: Parsing DOM to fill "Bean"

I have a question concerning a good strategy on how to fill a data "bean" with data inside an xml file. The bean might look like this: class Person { var $id; var $forename = ""; var $surname = ""; var $bio = new Biography(); } class Biography { var $url = ""; var $id; } the xml subtree containing the info might look lik...

How get DOM elements with a regular expresion in javascript?

For example, I want all the elements with an ID "hide_" + a value. This function must to return "hide_1" and "hide_30", etc, depending of the elements of the page. ...

Deriving an HTMLElement Object from jQuery Object

I'm doing a fairly exhaustive series of DOM manipulations where a few elements (specifically form elements) have some events. I am dynamically creating (actually cloning from a source element) several <select> boxes and assigning a change() event to them. The change event executes, and within the context of the event, "this" is the HTM...

Help with accessing a pre-existing window AFTER opener is refreshed!

Alright, I'm at my wit's end on this issue. First, backstory. I'm working on a video management system where we're allowing users, when adding new content, to upload and, optionally, transcode a media file. We're using Java applet for the browser-based FTP client. What I want to do is allow a user to initiate an upload and then send th...