Error Document.getelementsbytagname Is Not A Function
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site
Javascript Getelementsbytagname Is Not A Function
About Us Learn more about Stack Overflow the company Business Learn more about element.getelementsbytagname is not a function html2canvas hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss xmldoc.getelementsbytagname is not a function Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up document.getElementByTagName is not a
Typeerror: Getelementsbytagname Is Not A Function
function up vote 2 down vote favorite The code supposed to be use javascript between the script tags that consists of a mouseover event, and the list items in the HTML page must be styled as follows: normal - black, 12, bold and over yellow, 15, bold, italic.
- item 1
- item 2 javascript share|improve this question edited Apr 9 '13 at 8:16 lifetimes 40.1k108499 asked Apr 3 '13 at 10:11 Welcome Mohlala 11124 add a comment| 2 Answers 2 active oldest votes up vote 4 down vote That's because the correct function name is getElementsByTagName and not getElementByTagName. var items = document.getElementsByTagName("li"); This will return a Nodelist of elements with that particular tag name (in this case, all list items in the document). Then, you could target your li's specifically as you wish, for example: items[0].style.color = "yellow"; // first li is yellow when mouseover items[1].style.color = "red"; // second li is red when mouseover etc. share|improve this answer edited May 31 '13 at 14:24 answered Apr 3 '13 at 10:12 lifetimes 40.1k108499 2 The problem is, item is now a NodeList, and should be renamed to items. –Jan Dvorak Apr 3 '13 at 10:15 @JanDvora
here for a quick overview of the site Help Center Detailed answers to any questions you cannot read property 'getelementsbytagname' of undefined might have Meta Discuss the workings and policies of this site
Form.getelementsbytagname Is Not A Function
About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or table.getelementsbytagname is not a function posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of http://stackoverflow.com/questions/15784538/document-getelementbytagname-is-not-a-function 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up getElementsByTagName is not a function up vote 2 down vote favorite I am really struggling this. I am wanting to change the src attribute of an img tag and get the error message getElementsByTagName is not http://stackoverflow.com/questions/29944004/getelementsbytagname-is-not-a-function a function. The following is my test markup
script document.getElementsByClassName('logo').getElementsByTagName('img')[0].src ="/b.jpg"; Any advice is appreciated. javascript html share|improve this question asked Apr 29 '15 at 12:38 dcs 654 because getElementsByClassName returns a collection. –epascarello Apr 29 '15 at 12:40 possible duplicate of Why getElementsByClassName does not work for me? What does it return? –JJJ Apr 29 '15 at 12:42 add a comment| 4 Answers 4 active oldest votes up vote 5 down vote accepted getElementsByClassName return a collection. So you just have to do this : document.getElementsByClassName('logo')[0].getElementsByTagName('img')[0].src ="/b.jpg"; share|improve this answer edited Apr 29 '15 at 12:43 answered Apr 29 '15 at 12:40 Anthony Granger 31419 add a comment| up vote 1 down vote document.getElementsByClassName returns a list of all the classes in the document. Try document.getElementsByClassName("logo")[0] to get the first class. share|improve this answer answered Apr 29 '15 at 12:41 CosX 373415 add a comhere for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn http://stackoverflow.com/questions/15995124/getelementbyname-returns-type-error more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping https://github.com/niklasvh/html2canvas/issues/304 each other. Join them; it only takes a minute: Sign up getElementByName returns Type Error? up vote 1 down vote favorite 1 My code: var isSomethingChecked = (document.getElementByName("koalaCheck").checked || document.getElementByName("kangarooCheck").checked); Why does this code throw an exception called is not "Type Error"? javascript checked unchecked share|improve this question edited Apr 14 '13 at 2:37 Ian 30.5k76082 asked Apr 14 '13 at 2:32 jth41 62142772 Because getElementByName is probably returning null. –zzzzBov Apr 14 '13 at 2:34 A TypeError is most commonly thrown when you try to access a value that is unexpectedly null or undefined. A TypeError can also be thrown if you use the operator on a value that is not is not a a constructor or if you pass too many arguments to a built-in function. –999k Apr 14 '13 at 2:35 @zzzzBov Or because the method doesn't exist... –Ian Apr 14 '13 at 2:35 Vague title is unlikely to be useful to future visitors to the site. –Raymond Chen Apr 14 '13 at 2:37 @RaymondChen Good point, changed it so it hopefully helps –Ian Apr 14 '13 at 2:37 | show 7 more comments 3 Answers 3 active oldest votes up vote 6 down vote accepted There is no function called getElementByName. what you need is getElementsByName which returns an array of all of the elements that have that name. so you can use: var isSomethingChecked = (document.getElementsByName("koalaCheck")[0].checked || document.getElementsByName("kangarooCheck")[0].checked); share|improve this answer edited Apr 14 '13 at 2:42 answered Apr 14 '13 at 2:36 Omar Jackman 10.5k23056 A little explanation of what you changed would be useful. –jfriend00 Apr 14 '13 at 2:41 @jfriend00 done! –Omar Jackman Apr 14 '13 at 2:43 so can you do something like this? var isSomethingChecked = (document.getElementsByName("koalaCheck", "kangarooCheck").checked) –jth41 Apr 14 '13 at 2:49 @John no, you cant. –Omar Jackman Apr 14 '13 at 9:08 @jfriend00 - What was changed is the function name has an "S" added to it at the end of Elements since getEl
Sign in Pricing Blog Support Search GitHub This repository Watch 363 Star 7,010 Fork 1,584 niklasvh/html2canvas Code Issues 494 Pull requests 51 Projects 0 Wiki Pulse Graphs New issue TypeError: element.getElementsByTagName is not a function #304 Closed Topgoona opened this Issue Dec 1, 2013 · 8 comments Projects None yet Labels None yet Milestone No milestone Assignees No one assigned 4 participants Topgoona commented Dec 1, 2013 Hi, I've been trying to get your script to work for a day or 2 now. I'm trying to capture the contents of a div and save them to image file. I have the file save part working ok but image is not being captured. I think I may be missing something. I.m getting this error (TypeError: element.getElementsByTagName is not a function) and firebug points to this line of code in your script . domImages = element.getElementsByTagName('img'), // Fetch images of the present element only imgLen = domImages.length, link = doc.createElement("a"), supportCORS = (function( img ){ return (img.crossOrigin !== undefined); })(new Image()), timeoutTimer; The capture function I am using is function capture() { html2canvas( $('#voucher_container'), { logging: true, onrendered: function( canvas ) { var img = canvas.toDataURL(); $('#img_val').attr('value', img); document.getElementById("myForm").submit(); } }); } Any code inside the onrendered callback is not executed. Any help/advice you could give me would be greatly appreciated. mesutcakir commented Dec 2, 2013 I have a this problem. brcontainer commented Dec 3, 2013 Add an example of the problem with http://jsfiddle.net/ Topgoona commented Dec 3, 2013 Hi br. Thank you for the reply. I've had an attempt on jsfiddle here http://jsfiddle.net/Topgoona/2fZuX/6/. Like I said I'm trying to save an image of the voucher but keep coming back with empty file. Obviously the form submit won't work on jsfiddle but it's the div capture I am having trouble with. Thanks for your help. brcontainer commented Dec 3, 2013 Replace body.append(canvas); by document.body.appendChild(canvas);, see (working): http://jsfiddle.net/2fZuX/10/ Topgoona commented Dec 3, 2013 Thank you so much for the help br. Seems that I've been looking at the wrong area. Would you have an example of a way to POST and save the created image to file on the server. Thanks again for your help. Very much appreciated brcontainer commented Dec 3, 2013 @Topgoona Recommend using new FormData() eg. http://stackoverflow