getelementsbytagname

using document.getElementsByTagName on a page with iFrames - elements inside the iframe are not being picked up

和自甴很熟 提交于 2019-12-01 20:53:48
newer to javascript. On my page (asp.net application, vb as serverside language), I am using document.getElementsByTagName("img") to get all img tagged html items. I am noticing one in particular does not show up in this list (I was able to put them into an array and access the items individually - code below). This item is is contained inside an iframe (the iframe doesn't use SRC or anything else, just defined then the html inside it is right there in the source, doesnt load from another page - this is automatically generated by a crystal reports viewer generated at runtime, which is why I am

using document.getElementsByTagName on a page with iFrames - elements inside the iframe are not being picked up

房东的猫 提交于 2019-12-01 19:28:58
问题 newer to javascript. On my page (asp.net application, vb as serverside language), I am using document.getElementsByTagName("img") to get all img tagged html items. I am noticing one in particular does not show up in this list (I was able to put them into an array and access the items individually - code below). This item is is contained inside an iframe (the iframe doesn't use SRC or anything else, just defined then the html inside it is right there in the source, doesnt load from another

Why can I not remove a child element I've just found? NOT_FOUND_ERR

爷,独闯天下 提交于 2019-11-30 21:58:43
问题 I'm building a script which has to patch XML files, including replacing one list of elements with another. The following function applies a patch (involving a possibly empty list of elements with the same name) onto a parent Element's list of elements by the same name (also possibly an empty list). (This is only a small part of the patching logic). Why, when I run the code, do I get the following error? org.w3c.dom.DOMException: NOT_FOUND_ERR: An attempt is made to reference a node in a

Can I select multiple tags using getElementsByTagName?

妖精的绣舞 提交于 2019-11-30 05:34:52
I'm using a javascript snippet in order for visitors to my site to increase the font size on all paragraphs using the following javascript: function increaseFontSize() { var paragraphs = document.getElementsByTagName('p'); for(i=0;i<paragraphs.length;i++) { if(paragraphs[i].style.fontSize) { var s = parseInt(paragraphs[i].style.fontSize.replace("px","")); } else { var s = 14; } if(s != max) { s += 1; } paragraphs[i].style.fontSize = s+"px" } } How can I also include "li" to this code so that "p" and "li" are the selected elements that are affected? I would also like to avoid adding a class or

getElementsByTagName().length returns zero

给你一囗甜甜゛ 提交于 2019-11-30 03:13:24
问题 I am trying to do a simple thing such as: var elements = document.getElementsByTagName("input"); console.log(elements); console.log(elements.length); The console.log(elements) shows the NodeList containing 28 input elements, but the elements.length is always 0. I've also seen this getElementsByTagName("div").length returns zero for any webpage however I didn't understand what exactly is the reason for it happening and how to fix it. I've also noticed that this happens on both Firefox, IE,

DOM 节点列表

六月ゝ 毕业季﹏ 提交于 2019-11-30 01:03:45
原文:http://www.w3pop.com/learn/view/doc/dom_nodes_nodelist/ DOM 节点列表 -------------------------------------------------------------------------------- 作者:w3pop.com 翻译/整理:w3pop.com 发布:2007-04-29 修改:2007-08-30 浏览:3258 :: :: DOM 节点 DOM 解析 DOM NodeList and NamedNodeMap DOM NodeList [节点列表]对象和 NamedNodeMap [指定节点映射]对象 This chapter explains what a NodeList is, and what a NamedNodeMap is. It also explains the differences between them. 通过本章的学习,你将学习什么是NodeList [ 节点列表 ],什么是NamedNodeMap[ 指定节点映射 ],以及它们之间存在着哪些不同。 -------------------------------------------------------------------------------- DOM NodeList DOM

DOM 节点列表

不羁的心 提交于 2019-11-30 01:02:10
原文:http://www.w3pop.com/learn/view/doc/dom_nodes_nodelist/ DOM 节点列表 -------------------------------------------------------------------------------- 作者:w3pop.com 翻译/整理:w3pop.com 发布:2007-04-29 修改:2007-08-30 浏览:3258 :: :: DOM 节点 DOM 解析 DOM NodeList and NamedNodeMap DOM NodeList [节点列表]对象和 NamedNodeMap [指定节点映射]对象 This chapter explains what a NodeList is, and what a NamedNodeMap is. It also explains the differences between them. 通过本章的学习,你将学习什么是NodeList [ 节点列表 ],什么是NamedNodeMap[ 指定节点映射 ],以及它们之间存在着哪些不同。 -------------------------------------------------------------------------------- DOM NodeList DOM

Use vanilla javascript to add / remove class to a different element after clicking on another one

本秂侑毒 提交于 2019-11-29 12:55:37
问题 I have looked through a number of similar questions but can not find a specific example of one that answers in vanilla JS how to add and remove a class to a different element from the one clicked on. I know it has something to do with setting up a loop and iterating through the elements, but I got lost in the exact process. I have a number of elements with a class name of faq-container and when I click on any of them, I would like the class faq-display added to the body tag. I know I have to

How to insert metatag without using jquery append?

左心房为你撑大大i 提交于 2019-11-29 04:21:20
I used the following jquery to insert a metatag into a html document. <script type="text/javascript"> if(screen.width>=320 && screen.width<=767){ $('head').append('<meta id="viewport" name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">');} </script> If possible, I'd like to insert the metatag without using jquery. Anyone have any ideas how I can do that? I believe I will probably need to use document.getElementByTagName but I'm not sure how. Just in case you are wondering, I am inserting the metatag into my html to to optomize the site for viewing with

Javascript getElement by href?

自闭症网瘾萝莉.ら 提交于 2019-11-28 05:17:07
I've got the script below var els = document.getElementsByTagName("a"); for(var i = 0, l = els.length; i < l; i++) { var el = els[i]; el.innerHTML = el.innerHTML.replace(/link1/gi, 'dead link'); } However this searches through the page and takes about 20 seconds to do it as there are LOTS of links. However I only need to target the a 's that have a specific href , for eg. "http://domain.com/" So ideally I'd like to be able to do this in a similar fashion to jQuery, but without using a framework. So something like var els = document.getElementsByTagName("a[href='http://domain.com']"); How would