Search Results

Search found 602 results on 25 pages for 'getelementsbytagname'.

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

  • Can't access variables from dynamically loaded javascript

    - by Menno
    I'm using a fairly simple system to load javascript dynamically: include = function (url) { var e = document.createElement("script"); e.src = url; e.type="text/javascript"; document.getElementsByTagName("head")[0].appendChild(e); }; Let's say I have a file test.js which has the following contents: var foo = 4; Now, in my original script, I want to use include(test.js); console.log(foo); However, I get a 'foo has not been defined' error on this. I'm guessing it has to do with the dynamic script being included as the last child of the <head> tag. How can I get this to work?

    Read the article

  • [webbrowser component]

    - by Eduardo Ghidini
    I'm using webbrowser component to show an page of articles. My webbrowser will, if the user read an article, to mark it like read. So, i'm need to each articles of the page (these articles are dynamic) and verify, in a local xml how articles are read.To article read i'm set a determinated css class,and if not, another css class. To do it, i'm checking all elements of type "DIV" in page using this code line: HtmlElementCollection col = webBrowser.Document.GetElementsByTagName("div"); I'm wanna filter the div's to get only 'divs' that i will change and not all div's of page Somebody can help me? Thanks

    Read the article

  • Javascript: Perform function on form submit

    - by flight643
    Hopefully this is a pretty simple question! I've got the code working in jQuery to listen for a specific form on a page to be submitted and perform an alert when it is.. I.e.: The form itself doesn't have a name so I am targetting the form within a specific form ID. $("#content form").submit(function() { alert("lorem ipsum dolor?"); }); What would be the syntax for performing this in javascript alone without using jquery? For example, I have this code (below) and just am unsure of how to listen for the form to be submitted to perform an action.. var submitform = document.getElementById("content").getElementsByTagName("form"); Thanks!

    Read the article

  • How does one validate html that's generated from JS running in the browser?

    - by Henry Rose
    The page in question has very skeletal html sent over the wire to facilitate the building of a complicated UI in javascript. I'm now encountering a strange browser compatibility issue that feels very much like I've got a markup problem somewhere on the page. I've validated the page as it comes across the wire using the W3C tool and ensured there are no issues in that html. I've also tried validating the output of running on the browser console: document.getElementsByTagName('html')[0].outerHTML I find that the output of the above introduces lots of new issues, such as removing the trailing '/' in self closing tags. This added noise is distracting, but it also makes me uneasy about validating this method. How do you validate markup that's rendered client side?

    Read the article

  • Javascript Replace Child/Loop issue

    - by Charles John Thompson III
    I have this really bizarre issue where I have a forloop that is supposed to replace all divs with the class of "original" to text inputs with a class of "new". When I run the loop, it only replaces every-other div with an input, but if I run the loop to just replace the class of the div and not change the tag to input, it does every single div, and doesn't only do every-other. Here is my loop code, and a link to the live version: live version here function divChange() { var divs = document.getElementsByTagName("div"); for (var i=0; i<divs.length; i++) { if (divs[i].className == 'original') { var textInput = document.createElement('input'); textInput.className = 'new'; textInput.type = 'text'; textInput.value = divs[i].innerHTML; var parent = divs[i].parentNode; parent.replaceChild(textInput, divs[i]); } } }

    Read the article

  • Disable link in UIWebView in appearance and function

    - by Peter
    Hello, I wish to disable the href links on a UIWebView. First, I want the look of the link to change so the user doesn't think it is clickable. Second, I want the actual link to not be able to be tapped. I do not want to try webView:shouldStartLoadWithRequest:navigationType: since that not change the appearance of my links. I found this answer: Disabling visible links in UIWebView But the above hasn't worked for me. This is my code: NSString* s=[[NSString alloc] initWithFormat:@"for (a in document.getElementsByTagName(\"a\")) {a.href = \"\";}"]; [myWebView stringByEvaluatingJavaScriptFromString:s]; I've been working on this for hours, any suggestions are appreciated! Thanks!

    Read the article

  • Appending target="_blank" to links in an iframe without using <body onload>

    - by CincauHangus
    I'm trying to change the links in an iframe to load in a new window instead of the iframe itself. Currently I use this code in head: $(document).ready(function() { var oIFrame = document.getElementById("iframeID"); var oDoc = (oIFrame.contentWindow || oIFrame.contentDocument); if(oDoc.document) oDoc = oDoc.document; var links = oDoc.getElementsByTagName("a"); for(var i=0; i<links.length; i++) { links[i].target="_blank"; } }); However, the code above is triggered before the iframe is fully loaded with its contents. I know this code would work if it's triggered in the body onload attribute, but I'd like to avoid that method and implement it in a function or a file instead.

    Read the article

  • Merging getComputedStyle and evaluate in Greasemonkey

    - by Keheliya Gallaba
    I need to get all the text nodes with a certain font-face in a page to an array. I tried.. textnodes = document.evaluate("//* [@style='font-family: foo;']//text()[" + "not(ancestor::script) and not(ancestor::style)]", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); and textnodes = document.evaluate("//* [@face='foo']//text()[" + "not(ancestor::script) and not(ancestor::style)]", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); But these does not work with pages that is styled by external CSS files. Seems getComputedStyle() is the way to go. I think what I need is something like.. var tags = document.getElementsByTagName('*'); for (var i in tags) { var style = getComputedStyle(tags[i], ''); if (style.fontFamily.match(/foo/i)) { textnodes.push(tags[i]); } } But text nodes were not returned in this method. Is there anyway I can use a hybrid of xpath evaluate() and getComputedStyle() or any other way to achieve this?

    Read the article

  • Dynamically replace HTML element in UIWebView

    - by Skie
    I have some HTML loaded in WebView like this: <html><head></head><body>before <myTag>Content</myTag> after</body></html> I want to replace element myTag with custom text so it should look like: <html><head></head><body>before ____MY_CUSTOM_TEXT___ after</body></html> Also I can't change initial HTML. How I can do this with JavaScript? My not finished code: var elements = document.getElementsByTagName( 'myTag' ); var firstElement = elements[0]; var parentElement = firstElement.parentNode; var html = parentElement.innerHTML; parentElement.innerHTML = html.replace(?????, '____MY_CUSTOM_TEXT___'); I don't know how to get string value of element to replace (?????).

    Read the article

  • how do you get the response back into the instance of the object?

    - by randomdev
    If you've written a class in JavaScript that calls a remote service's API, and that remote API offers a callback, how do you get the response back into the instance of the object that made the request? I'll try to give you a very basic example FOO for making cross domain calls to BAR service which offers a callback. Please ignore the usual security concerns, (I own both servers). function FOO() { this.response = null; this.execute = function(url) { var script = document.createElement('script'); script.src = url; document.getElementsByTagName('head')[0].appendChild(script); } this.catch = function(response) { this.response = response; } } var sample = new FOO(); sample.execute('http://barservices.com/sample/?callback={ plshelphere: this.catch}'); I have a way to make this work, but I'm curious if there is an "accepted approach" here. Anyone have thoughts for me?

    Read the article

  • missing ) in parenthetical

    - by Elgoog
    I'm modifying BSN's Autosuggest script so it will work with codeigniter, the only proble is I cant seem to figure out why it displays "missing ) in parenthetical" says the problem is around else _b.AutoSuggest.prototype.setSuggestions = function (req, input) { if (input != this.fld.value) return false; this.aSug = []; if (this.oP.json) { var jsondata = eval('(' + req.responseText + ')'); for (var i=0;i<jsondata.results.length;i++) { this.aSug.push( { 'id':jsondata.results[i].id, 'value':jsondata.results[i].value, 'info':jsondata.results[i].info } ); } } else { var xml = req.responseXML; // traverse xml // var results = xml.getElementsByTagName('results')[0].childNodes; for (var i=0;i<results.length;i++) { if (results[i].hasChildNodes()) this.aSug.push( { 'id':results[i].getAttribute('id'), 'value':results[i].childNodes[0].nodeValue, 'info':results[i].getAttribute('info') } ); } } this.idAs = "as_"+this.fld.id; this.createList(this.aSug); }; Any help would be appreciated, i'm not very good at JS

    Read the article

  • What would be jQuery equivalent of this sf hover suckerfish code?

    - by metal-gear-solid
    What would be jQuery equivalent of this sf hover suckerfish code? <script> sfHover = function() { var sfEls = document.getElementById("navbar").getElementsByTagName("li"); for (var i=0; i<sfEls.length; i++) { sfEls[i].onmouseover=function() { this.className+=" hover"; } sfEls[i].onmouseout=function() { this.className=this.className.replace(new RegExp(" hover\\b"), ""); } } } if (window.attachEvent) window.attachEvent("onload", sfHover); </script>

    Read the article

  • Perform function on form submit

    - by flight643
    Hopefully this is a pretty simple question! I've got the code working in jQuery to listen for a specific form on a page to be submitted and perform an alert when it is.. I.e.: The form itself doesn't have a name so I am targetting the form within a specific form ID. $("#content form").submit(function() { alert("lorem ipsum dolor?"); }); What would be the syntax for performing this in javascript alone without using jquery? For example, I have this code (below) and just am unsure of how to listen for the form to be submitted to perform an action.. var submitform = document.getElementById("content").getElementsByTagName("form"); Thanks!

    Read the article

  • get js file query param from inside it

    - by vsync
    I load this file with some query param like this: src='somefile.js?userId=123' I wrote the below function in 'somefile.js' file that reads the 'userId' query param but I feel this is not the best approach. Frankly, its quite ugly. Is there a better way? function getId(){ var scripts = document.getElementsByTagName('script'), script; for(var i in scripts){ if( scripts.hasOwnProperty(i) && scripts[i].src.indexOf('somefile.js') != -1 ) var script = scripts[i]; } var s = (script.getAttribute.length !== undefined) ? script.getAttribute('src') : script.getAttribute('src', 2); return getQueryParams('userId',s); };

    Read the article

  • Update FB:Like URL Dynamically using JavaScript

    - by br4inwash3r
    i'd like to change the URL to like of an FB:Like button dynamically using javascript. right now i've been able to change the href attribute of the fb:like tag (i've pasted the code below). but that doesn't work. perhaps i have to re-initiate the FB:Like button, but so far i can't figure out how.. function update_share(container, url) { // update fb:like href value var container = container[0] || document.body; var button = container.getElementsByTagName('fb:like'); button[0].setAttribute('href', url); } any help would be appreciated. thx..

    Read the article

  • Javascript form validation only works in firefox

    - by Logic Artist
    Hello, I am relatively new to Javascript so I'm hoping this is a simple mistake. I building a generic form validation function that is called on the form's onSubmit. The function loops through all the form's child elements, looks for certain classes, and analyzes the contents of the appropriate fields. If it finds something missing or erroneous, it displays the appropriate error message div and returns false, thus preventing the form from being submitted to the php page. It works well in firefox 3.6.3, but in every other browser I've tested (Safari 4.0.4, Chrome 4.1, IE8) it seems to ignore the onSubmit and jump straight to the php processing page. HTML CODE: <form name='myForm' id='myForm' action='process_form.php' method='post' onSubmit="return validateRequired('myForm')"> <fieldset class="required radioset"> <label for='selection1'> <input type='radio' name='selection' id='selection1' value='1'/> Option 1 </label> <label for='selection2'> <input type='radio' name='selection' id='selection2' value='2'/> Option 2 </label> <label for='selection3'> <input type='radio' name='selection' id='selection3' value='3'/> Option 3 </label> <label for='selection4'> <input type='radio' name='selection' id='selection4' value='4'/> Option 4 </label> <div class='errorBox' style='visibility:hidden'> Please make a selection </div> </fieldset> <fieldset class="required checkset"> <label> Choice 1 <input type='checkbox' name='choices' id='choice1' value='1'/> </label> <label> Choice 2 <input type='checkbox' name='choices' id='choice2' value='2'/> </label> <label> Choice 3 <input type='checkbox' name='choices' id='choice3' value='3'/> </label> <label> Choice 4 <input type='checkbox' name='choices' id='choice4' value='4'/> </label> <div class='errorBox' style='visibility:hidden'> Please choose at least one </div> </fieldset> <fieldset class="required textfield" > <label for='textinput1'> Required Text: <input type='text' name='textinput1' id='textinput1' size='40'/> </label> <div class='errorBox' style='visibility:hidden'> Please enter some text </div> </fieldset> <fieldset class="required email textfield"> <label for='email'> Required Email: <input type='text' name='email' id='email' size='40'/> </label> <div class='errorBox' style='visibility:hidden'> The email address you have entered is invalid </div> </fieldset> <div> <input type='submit' value='submit'> <input type='reset' value='reset'> </div> </form> JAVASCRIPT CODE: function validateRequired(id){ var form = document.getElementById(id); var errors = 0; var returnVal = true; for(i = 0; i < form.elements.length; i++){ var elem = form.elements[i]; if(hasClass(elem,"required")){ /*RADIO BUTTON or CHECK BOX SET*/ if(hasClass(elem,"radioset") || hasClass(elem,"checkset")){ var inputs = elem.getElementsByTagName("input"); var check = false; for(j = 0; j < inputs.length; j++){ if(inputs[j].checked){ check = true; } } if(check == false){ errors += 1; showError(elem); } else { hideError(elem); } } /*TEXT FIELD*/ else if(hasClass(elem,"textfield")){ var input = elem.getElementsByTagName("input"); if(input[0].value == ""){ errors += 1; showError(elem); } else { hideError(elem); /*EMAIL ADDRESS*/ if(hasClass(elem,"email")){ if(isValidEmail(input[0].value) == false){ errors += 1; showError(elem); } else { hideError(elem); } } } } } } if(errors > 0){ returnVal = false; } else { returnVal = true; } return returnVal;} I know this is a lot of code to look at, but any help would be appreciated. Since it works fine in one browser, Im not sure how to start debugging. Thanks Andrew

    Read the article

  • Access attribute values of empty element tag in xml

    - by meenakshik
    Hello, I have a xml where I got some empty complex elements and I need to access the attribute values of this element. <test> <a> <abc-metadata name="testData" value="This is a test"/> </a> </test> I want to get hold of the 'testData' and 'This is a test' values. I do read the document and I tried accessing it document.getElementsByTagName . I am sure there is some way to access attributes of element tags but somehow it throws me nullpointer exception. Thanks in advance

    Read the article

  • javascript xml saving problem

    - by Guru
    hi there, I want to modify some data on XML file residing on server side by using javascript. I'm using following code var xh; if(window.XMLHttpRequest) { xh=new XMLHttpRequest(); } else { xh=new ActiveXObject("Microsoft.XMLHTTP"); } xh.open("get","books.xml",false); xh.send(""); var xdoc=xh.responseXML; var x=xdoc.getElementsByTagName("title"); x[0].getAttributeNode("lang").nodeValue="zh"; xh.save("books.xml"); but its not working Thanks in advance, Guru

    Read the article

  • How to integrate a GWT app into another Web-Framework?

    - by tigger
    I need the ability to load and start a GWT App at any time in an Echo2 environment. My first approach was to load and execute the nocache.js in a Client-Server sync using var script = document.createElement("script"); script.setAttribute("src",javascriptURI); script.setAttribute("type","text/javascript"); document.getElementsByTagName('body')[0].appendChild(script); This call basically works, but when the script is executed it operates on an EMPTY document instead of the current document of the Echo2 application. Has the script to be somehow initialized first or is there any event required? The GWT application/script works fine if it's included in the start-up HTML of the application, so I assume the GWT App to be correct. The original standalone HTML of the GWT App has the HTML script tag in the body as well.

    Read the article

  • greasemonkey code modification

    - by muqtar
    Hi,all.. A user has helped me find hidden values in a page and display it using alert. If there are radio buttons and one of them is related to this value,is there a way to select the radio button automatically rathar than displaying the value in alert box.. Thanks... the code is as follows: var inputs = document.getElementsByTagName('input'); for (i=0; i<inputs.length; i++) { if (inputs[i].getAttribute("name") == "ans") { alert(inputs[i].getAttribute("value")); } } this "value" must be selected in the radio button rathar than alerting...

    Read the article

  • xml parsing takes extra spaces.

    - by SDK
    I have been trying to write/parse xml file in python. The tags are very simple <main> <data> abcdef </data> </main> I have written this xml using xml document writer from xml.dom.minidom. How-ever when i try to parse this and try to fetch data-text value, i get 'abcdef' with spaces/carriage return/newline characters in beg and end. Does parsing does not take of indenting spaces? Following is the parsing snippet (ref from net) dom = parseString(data) clipTag = dom.getElementsByTagName('clipdata')[0].toxml() clipData=clipTag.replace('<clipdata>','').replace('</clipdata>','') Kindly suggest.

    Read the article

  • iframe height is giving wrong value

    - by user1668527
    I have HTML page which contains line: <iframe id="xyz" width="900" height="250" scrolling="no"..></iframe> From my firefox extension i'm trying to get the iframe height. so i'm registering the browser to a event as follow in my extension: appcontent.addEventListener("DOMContentLoaded",myfunction); where appcontent is browser object, myfunction(event): function { var framelist =window.content.document.getElementsByTagName("iframe"); for(var i=0;i<framelist.length;i++) { if(framelist[i].id == "xyz") var frameheight=framelist[i].height; } } when i tried to load this page intially frameheight gives 250 as per in html page but then it gives 0 as height. What would be the cause for this behaviour. is any other script changing the value of iframe height in between ? Help me

    Read the article

  • WebKit & Objective-C: how to parse a HTML string into a DOMDocument?

    - by Rinzwind
    How do you get a DOMDocument from a given HTML string using WebKit? In other words, what's the implementation for DOMDocumentFromHTML: for something like the following: NSString * htmlString = @"<html><body><p>Test</body></html>"; DOMDocument * document = [self DOMDocumentFromHTML: htmlString]; DOMNode * bodyNode = [[document getElementsByTagName: @"body"] item: 0]; // ... etc. This seems like it should be straightforward to do, yet I'm still having trouble figuring out how :( ...

    Read the article

  • Merging XMLTextReaders in C#

    - by smithchelluk
    I have a website that needs to pull information from two diffferent XML data sources. Originally I only need to get the data from one source so I was building a URL in the backend that went and retrieved the data from the XML site and then parsed and rendered it in the front end of the website. Now I have to use a 2nd data source and merge the result sets (which are identically structured XML) into one result set. Here is the code I am currently using to get one XML feed. sUrl = sbUrl.ToString(); //The URL for the XML feed XmlDocument xDoc = new XmlDocument(); StringBuilder oBuilder = new StringBuilder(); //The parsed HTML output XmlTextReader oXmlReader = new XmlTextReader(sUrl); oXmlReader.Read(); xDoc.Load(oXmlReader); XmlNodeList List = xDoc.GetElementsByTagName("result"); foreach (XmlNode node in List) { XmlElement key = (XmlElement)node; //BUILD THE OUTPUT HERE } Thanks in advance for your help.

    Read the article

  • How to get option value (javascript)

    - by Mahmoud
    Below are the options that i have in my code <label id="subn"> <select name="subs" id="subs"> <option value="nothing">Choose a Subject</option> <option value="General Question">General Question</option> <option value="MemberShip Area">MemberShip Area</option> <option value="Others">Others</option> </select> </label> and i want to create a javascript that well check if the user select a subject other than the first below what i tried using if (document.getElementsByTagName('option') == "nothing"){ document.getElementById("subn").innerHTML = "Subject is Required!"; document.getElementById("subs").focus(); return false; }

    Read the article

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