dom

Click events in a jQuery Dialog occur twice?

Hello, I have been dealing with an odd problem that .click() events happen twice whenever placed in a jQuery Dialog. My simple test case is below and a live example is here <div id="popup" style="display: none"> <a href="javascript:void(0);" id="testlink">Test Link</a> <script type="text/javascript"> $('#testlink').cli...

Remove background image on image load

I'm loading image tags via AJAX and inserting them with the conventional .html(content) function in jQuery alongside a bunch of other HTML. However, this question still applies if you're loading a page from scratch. Now, I have a background image placeholder to be put there while the image loads. I want this background image to go away w...

Why doesn't PHP DOM include slash on self closing tags?

I have been using PHP's DOM to load an html template, modify it and output it. Recently I discovered that self-closing (empty) tags don't include a closing slash, even though the template file did. e.g. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"`"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; <html> <meta http-equ...

Can I pass a parameter directly to a .js file, and how do I get the value

Hi, I want to pass a parameter to some javascript using a single line of code, like this: <script language="JavaScript" src="courselist.js?subj=MATH" type="text/javascript" /> Inside the javascript file, how can I get the value of the parameter "subj"? Thanks ...

Observing for insertion of new DOM nodes and calling a method on them

I'm writing some javascript using jQuery to call a method on all nodes with class datepicker. Here's what I have: $('.datepicker').my_method(); This works as expected - it calls my_method. However, I want to be able to call my_method on all new nodes that are inserted into the DOM with the class datepicker. I want similar functiona...

InnerHTML including styles from stylesheets

Is there a way to get the innerHTML of a section of the page together with all style information that is used by the elements in that section(including styles that also come from corresponding stylesheets). So that when I insert the html somewhere else It will display with original styling. ...

How to get parent iframe element from inner page without knowing id?

Let's image that I have something like this: <html> ... <div> <iframe src="test.html" hash="r4d5f7"></iframe> <iframe src="test.html" hash="8f7x97"></iframe> <iframe src="test.html" hash="gg4v5e"></iframe> <iframe src="test.html" hash="e54f87"></iframe> </div> ... </html> test.html is empty page...

javascript: how to remove element on title

Hi everyone, As the title, how can I remove a div on the html title using javascript or jquery framework? I know it sounds weird but currently I'm working on a CMS template and the generate title has around the title <title><div id="title">Title of the page</div></title> Any help appreciated ...

PHP DOM append child with new line

Hello all, My name Rithy. I don't know how to add new line before appending a new node or element in the xml. My php: $dom = new DOMDocument(); $dom->formatOutput = true; $dom->preserveWhiteSpace = true; $dom->load($xml_file); $body = $dom->getElementsByTagName('body')->item(0); $newelement_seg = $dom->createElement('seg'); $da...

Can not use the location object is javascript

Hi everyone! I was making a page with frames. One is a treeview frame, the other is showing a report. When I click the item in the left frame, the report will display in the right frame. But after I click the first item, the location object in the right frame became unavailable! Which prevents me from opening a new report in the same f...

Run a javascript file on a set of html documents

I have a set of html documents on local disk to process. I need to load each document file as document object and run a piece of javascript code over it and store the result in a separate file. I would prefer to this from python though I'm open to any other suggestions too. I tried to do this through extensions in chrome and firefox b...

Modify the Google 'Add Bookmark' bookmarklet to store bookmark without popup?

The bookmarklet has the following code: javascript:(function(){var%20a=window,b=document,c=encodeURIComponent,d=a.open("http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk="+c(b.location)+"&amp;title="+c(b.title),"bkmk_popup","left="+((a.screenX||a.screenLeft)+10)+",top="+((a.screenY||a.screenTop)+10)+",height=420px,w...

PHP DOM, Find the text within a certain div

I am currently working a developer tracker for a game without using regex. I have hit a road block when trying to parse html at certain parts. What I am trying to parse: <td class="alt1" id="td_post_139718"> <!-- message, attachments, sig --> <!-- icon and title --> <div class="smallfont"> <img class="in...

"touch" a DOM element

Is there a handy way to "touch" a DOM element? I'd like to remove the element and insert it again at the same position. Something like this: element.parentNode.removeChild(element).appendChild(element); except that appendChild inserts the element as the last sibling. ...

Augment a DOM element

Is it possible to augment a DOM element by adding a new property to it as augmenting a normal JavaScript object? For example, can we add a new property of a button or an input, say a value that indicates when was the last time user click on it? ...

select all checkbox by one checkbox not working.

following is my code, can any one tell me whats going wrong. <input type="checkbox" name="Chk[]" value="<?php echo($arr['id']); ?>" onClick="Click()" id="CK">// all checkboxex <input onClick="selectall()" type="checkbox" value="yes" name="c1">// one checkbox /*function called*/ function selectall() { if(document.frm.chk.val...

Strange behavior of button: calling "onclick" parent's element instead of itself (HTML Button)

Hi all! I have following structure of web application, for which I'm automating testing: <em unselectable="on" class="x-btn-split"> <button type="button" class="x-btn-text " id="ext-gen523" title="Add Options">Add</button> </em> Both objects has event listeners,added viw JavaScript in some linked js-file (I don't know what f...

Get the position of a DOM element via x, y co-ordinates

Is there a way to select the top most DOM element at a certain x-y position with Javascript? So give x and y, what DOM element is there? ...

Replace/Add several DOM Elements: Efficient and robust Method?

I am in search for an efficient method to replace a couple of DOM Elements - if possible in one action only. It is needed for augmenting TextNodes. If a certain word is present, it shall be wrapped in span-Tags, to which an event handler needs to be assigned later. so if a text Node contains the word it needs to turn from -#textNode ...

Ruby on Rails: accessing form elements with javascript

Hello! I have a form with a set of links and hidden inputs like this: <div><%=link_to '&darr;', {}, {:href =>'#', :onclick => "return moveDown(#{photo.id});"}%></div> <%= photo_form.hidden_field :position %> How do I change input value when link is clicked without hard-coding input ids on client side? i dont want to use selector...