Search Results

Search found 2206 results on 89 pages for 'dom beau'.

Page 14/89 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • Using AJAX to get a specific DOM Element (using Javascript, not jQuery)

    - by Matt Frost
    How do you use AJAX (in plain JavaScript, NOT jQuery) to get a page (same domain) and display just a specific DOM Element? (Such as the DOM element marked with the id of "bodyContent"). I'm working with MediaWiki 1.18, so my methods have to be a little less conventional (I know that a version of jQuery can be enabled for MediaWiki, but I don't have access to do that so I need to look at other options). I apologize if the code is messy, but there's a reason I need to build it this way. I'm mostly interested in seeing what can be done with the Javascript. Here's the HTML code: <div class="mediaWiki-AJAX"><a href="http://www.domain.com/whatever"></a></div> Here's the Javascript I have so far: var AJAXs = document.getElementsByClassName('mediaWiki-AJAX'); if (AJAXs.length > 0) { for (var i = AJAXs.length - 1; i >= 0; i--) { var URL = AJAXs[i].getElementsByTagName('a')[0].href; xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { AJAXs[i].innerHTML = xmlhttp.responseText; } } xmlhttp.open('GET',URL,true); xmlhttp.send(); } }

    Read the article

  • Is DOM not being loaded ?

    - by Daniel
    I went through episode 88 (Dynamic menus) of the railscasts and when I try to load my *js.erb file in the browser shows me that my fetched data from the controller is getting there Controller def dynamic_departments @departments = Department.all end localhost:3000/javascripts/dynamic_departments.js var departments = new Array(); departments.push(new Array(1,'????',1)); departments.push(new Array(2,'???-???',2)); function facultySelected(){ faculty_id = $('falculty_id').getValue(); options = $('department_id').options; options.length = 1; departments.each(function(department){ if(department[0] == faculty_id){ options[options.length] = new Option(department[1],department[2]) } }); if(options.length == 1){ $('department_field').hide(); } else { $('department_field').show(); } } document.observe('dom:loaded', function(){ alert("DOM loaded"); //$('department_field').hide(); //$('faculty_id').observe('change',facultySelected); }); My routes.rb has the match ':controller/:action.:format' Still...after the page's loaded and I change the value of my collection_select or select nothing happens.What am I missing? *I called the 'alert' and commented the rest to test it....still nothing.

    Read the article

  • Selenium problem locating by DOM

    - by bartonlee
    Hi, I'm trying to use the DOM to locate a form element in Selenium but I can't get it to work. Even if I use the example in the Selenium documentation it still fails, for example with this html... <html> <body> <form id="loginForm"> <input name="username" type="text" /> <input name="password" type="password" /> <input name="continue" type="submit" value="Login" /> <input name="continue" type="button" value="Clear" /> </form> </body> <html> and this command in the Selenium IDE... verifyElementPresent with target... dom=document.forms['loginForm'] I get [error] false in the log. The 'getElementById' example in the documentation does work, but none of the others. Can someone explain what I'm doing wrong here? Thanks.

    Read the article

  • loading remote page into DOM with javascript

    - by scoobydoo
    I am trying to write a web widget which will allow users to display customized information (from my website) in their own web page. The mechanism I want to use (for creating the web widget) is javascript. So basically, I want to be able to write some javascript code like this (this is what the end user copies into their HTML page, to get my widget displayed in their page) <script type="text/javascript"> /* javascript here to fetch page from remote url and insert into DOM */ </script> I have two questions: how do I write a javascript code to fetch the page from the remote url? Ideally this will be PLAIN javascript (i.e. not using jQuery etc - since I dont want to force the user to get third party scripts jQuery which may conflict with other scripts on their page etc) The page I am fetching contains inline javascript, which gets executed in an body.onLoad event, as well as other functions which are used in response to user actions - my questions are: i). will the body.onLoad event be triggered for the retrieved document?. ii). If the retrieved page is dumped directly into the DOM, then the document will contain two <body> sections, which is no longer valid (X)HTML - however, I need the body.onLoad event to be triggered for the page to be setup correctly, and I also need the other functions in the retrieved page, for the retrieved page to be able to respond to the user interaction. Any suggestions/tips on how I can solve these problems?

    Read the article

  • Dojo addOnLoad, but is Dojo loaded?

    - by adamrice32
    I've encountered what seems like a chicken & egg problem, and have what I think is a logical solution. However, it occurred to me that others must have encountered something similar, so I figured I'd float it out there for the masses. The situation is that I want to use dojo's addOnLoad function to queue up a number of callbacks which should be executed after the DOM has completed rendering on the client side. So what I'm doing is as follows: <html> <head> <script type="text/javascript" src="dojo.xd.js"></script> ... </head> <body> ... <script type="text/javascript"> dojo.addOnLoad( ... ); dojo.addOnLoad( ... ); ... </script> </body> </html> Now, the issue is that I seem to be calling dojo.addOnLoad before the entire Dojo library has been downloaded the browser. This makes sense in a way, because the inline SCRIPT contents should be executed before the entire DOM is loaded (and the normal body onload callback is triggered). My question is this - is my approach sound, or would it make more sense to register a normal/standard body onload JavaScript callback to call a function, which does the same work that each of the dojo.addOnLoads is doing in the SCRIPT block. Of course, this begs the question, why would you ever then use dojo.addOnLoad if you're not guaranteed that the Dojo library will be loaded prior to using the library? Hopefully this situation makes sense to someone other than me. Seems like someone else may have encountered this situation. Thoughts? Best Regards, Adam Rice

    Read the article

  • How to access CSS generated content with JavaScript

    - by Boldewyn
    I generate the numbering of my headers and figures with CSS's counter and content properties: img.figure:after { counter-increment: figure; content: "Fig. " counter(section) "." counter(figure); } This (appropriate browser assumed) gives a nice labelling "Fig. 1.1", "Fig. 1.2" and so on following any image. Question: How can I access this from Javascript? The question is twofold in that I'd like to access either the current value of a certain counter (at a certain DOM node) or the value of the CSS generated content (at a certain DOM node) or, obviously, both information. Background: I'd like to append to links back-referencing to figures the appropriate number, like this: <a href="#fig1">see here</h> ------------------------^ " (Fig 1.1)" inserted via JS As far as I can see, it boils down to this problem: I could access content or counter via getComputedStyle: var fig_content = window.getComputedStyle( document.getElementById('fig-a'), ':after').content; However, this is not the live value, but the one declared in the stylesheet. I cannot find any interface to access the real live value.

    Read the article

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

    - by Robbie Groenewoudt
    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 Element #2 is added to element #3 Element #1 is modified but no changes are visible in the DOM of element #3 (which contains #1 and #2) A simplified sample code: <?php $doc1 = new DOMDocument(); $el1 = $doc1->createElement('h1', 'Hello'); $doc1->appendChild($el1); $doc2 = new DOMDocument(); $el2 = $doc2->createElement('h2', 'World'); $doc2->appendChild($el2); $doc3 = new DOMDocument(); $el3 = $doc3->createElement('h3', 'Today'); $doc3->appendChild($el3); // Import el1 into el2 $el1 = $doc2->importNode($el1, true); $el2->appendChild( $el1 ); $doc1 = $doc2; // Import el2 into el3 $el2 = $doc3->importNode($el2, true); //$el1 = $doc3->importNode($el1, true); Necessary? $el3->appendChild($el2); $doc2 = $doc3; // Modify el1 $el1->nodeValue = "Boo"; // This doesn't work? //$el2->nodeValue = "Boo"; // Changing element2 or 3 works... // Display result echo $doc3->saveHTML(); ?>` Any idea's on why modifying $el1 won't work? (While $el2 works fine) Or an easy way to set $el1 to the right element?

    Read the article

  • Where to place interactive objects in JavaScript?

    - by Chris
    I'm creating a web based application (i.e. JavaScript with jQuery and lots of SVG) where the user interacts with "objects" on the screen (think of DIVs that can be draged around, resized and connected by arraows - like a vector drawing programm or a graphical programming language). As each "object" contains individual information but is allways belonging to a "class" of elements it's obvious that this application should be programmed by using an OOP approach. But where do I store the "objects" best? Should I create a global structure ("registry") with all (JS native) objects and tell them "draw yourself on the DOM"? Or should I avoid such a structure and think of the (relevant) DOM nodes as my objects and attach the relevant data as .data() to them? The first approach is very MVC - but I guess the attachment of all the event handlers will be non trivial. The second approach will handle the events in a trivial way and it doesn't create a duplicate structure, but I guess the usual OO stuff (like methods) will be more complex. What do you recomend? I think the answer will be JavaScript and SVG specific as "usual" programming languages don't have such a highly organized output "canvas".

    Read the article

  • Performing an action on Parent/Child elements independently.

    - by Matt Weldon
    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 jQuery associated with my img that will do some other function (for the sake of argument I am going to display and alert box) like so: $("img[class=someImg]").click(function(event){ alert("Image clicked"); }); The issue I have come across is that when I click on the img, the event associated with the div is also triggered. I'm pretty sure that this is due to the way that jQuery (or indeed JavaScript) is handling the two DOM elements - clicking the img would require you to also technically click the div, thus triggering both events. Two questions then really: Is my understanding of the DOM/JavaScript flawed in some way or is this actually how things are occurring? Are there any jQuery methods that would allow me to perform actions on a child element without invoking those associated with its parent?

    Read the article

  • jQuery: responding to click event of element added to document after page load

    - by morpheous
    I am writing a page which uses a lot of in situ editing and updating using jQuery for AJAX. I have come accross a problem which can best be summarised by the workflow described below: Clicking on 'element1' on the page results in a jQuery AJAX POST Data is received in json format The data received in json format The received data is used to update an existing element 'results' in the page The received data is actual an HTML form I want jQuery to be responsible for POSTing the form when the form button is clicked The problem arises at point 6 above. I have code in my main page which looks like this: $(document).ready(function(){ $('img#inserted_form_btn').click(function(){ $.ajax({'type: 'POST', 'url': 'www.example.com', function($data){ $(data.id).html($data.frm); }), 'dataType': 'json'} }); }); However, the event is not being triggered. I think this is because when the document is first loaded, the img#inserted_form_btn element does not exist on the page (it is inserted into the DOM as the result of an element being clicked on the page (not shown in the code above - to keep the question short) My question therefore is: how can I get jQuery to be able to respond to events occuring in elements that were added to the DOM AFTER the page has loaded?

    Read the article

  • Proper way to communicate between divs in jquery?

    - by folder
    This is probably a simple question, and i'm just being dense. I've looked through a few jquery books and nothing has jumped out at me, i'm probably missing something. I'm looking for the 'proper', best practices way to communicate between divs/dom items on a page? For example, I have a page with 5 panels that display when a link is chosen, they hide/show/run some code that changes other pieces on the page. Something like this snippet: <ul> <li><div id="unique_name_1_anchor">Unique div 1</div></li> <li><div id="unique_name_2_anchor">Unique div 2</div></li> <li><div id="unique_name_3_anchor">Unique div 3</div></li> <li><div id="unique_name_4_anchor">Unique div 4</div></li> </ul> ...Somewhere else on the page <div id="unique_name_1_panel">Some panel 1 stuff here</div> <div id="unique_name_2_panel">Some panel2 stuff here<div> <div id="unique_name_3_panel">Some panel3 here</div> <div id="unique_name_4_panel">Some panel4 here</div> The concept being when as user clicks on a unique_name_X_anchor div, some action is performed on the corresponding panel (ie show/hide etc...). What I have been doing now is parsing the id ie ($(this).replace("_anchor","_panel") to get the div id of the other dom element. This just seems clunky and there must be a better/more proper way of doing this. Suggestions? Thanks

    Read the article

  • Javascript Uncaught Error: INDEX_SIZE_ERR: DOM Exception 1

    - by Travis
    The site is: http://www.clubloc.com/ And it works in firefox but not in google chrome. Internet explorer also has problems but thats pretty much a given when using HTML5 Canvas. Anyways I'm trying to figure out why it throws the error: Uncaught Error: INDEX_SIZE_ERR: DOM Exception 1 When the arrays clearly have all those elements, I even logged their size and it says 100. Any help/guidance would be greatly appreciated.

    Read the article

  • Javascript DOM ready without an entire framework

    - by Brian
    Hello, Does anyone know of a good javascript DOM ready library that I can use without loading an entire framework? I found one on google code that seems to work, but the library was posted in 2008 and I can't find any confirmation on up-to-date cross browser support. Thanks, Brian

    Read the article

  • Pass HTML-DOM to Flex's actionscript.

    - by raj
    Hi, All i want is to pass a HTML-Form (DOM object) from javascript to Actionscript. i saw this article on the net and tried a similar code. But when i execute the code in IE, it alerts : "Out of memory at line 18". I'm stuck here from yesterday. i'll post the mxml and html here.. The MXML : <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()"> <mx:Script> <![CDATA[ public function init() : void { if (ExternalInterface.available) { try { ExternalInterface.addCallback("populateFlashFile", populateFlashFile); } catch (error:SecurityError) { } catch (error:Error) { } } } public function populateFlashFile(window:*) : void { log.text = window.toString(); // just for checking if window has come to the function. window.document.write("Hello"); } ]]> </mx:Script> <mx:TextArea x="10" y="23" width="712" height="581" id="log"/> </mx:Application> The HTML : <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body scroll="no"> <input type="button" onclick="document.getElementById('Test').populateFlashFile(window);"/> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="Test" width="100%" height="100%" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"> <param name="movie" value="Test.swf" /> <param name="quality" value="high" /> <param name="bgcolor" value="#869ca7" /> <param name="allowScriptAccess" value="sameDomain" /> </object> </body> </html> The problem occors only when i pass some DOM object, if i pass some String it works.!!! i.e : <input type="button" onclick="document.getElementById('Test').populateFlashFile('some text here');"/> works great!

    Read the article

  • RIA: Manipulate DOM

    - by stephanos
    I want to display a website embedded in my own site and modify the DOM (e.g. change a button's color/size), similar to what Firebug is capable of. I'm aware of the security issues that arise - my plan is to use this approach to do live website usability testing (A/B style). I'm not limited to any specific RIA framework (yet would prefer Flex) - but it has to work without installing anything (so no AIR). Cheers :-)

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >