Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- </head>
- <input type=text value=xxx>
- <script type="text/javascript">
- if (!('forEach' in Array.prototype)) {
- Array.prototype.forEach= function(action, that /*opt*/) {
- for (var i= 0, n= this.length; i<n; i++)
- if (i in this)
- action.call(that, this[i], i, this);
- };
- }
- if (!('map' in Array.prototype)) {
- Array.prototype.map= function(mapper, that /*opt*/) {
- var other= new Array(this.length);
- for (var i= 0, n= this.length; i<n; i++)
- if (i in this)
- other[i]= mapper.call(that, this[i], i, this);
- return other;
- };
- }
- function getAllElements() {
- var elements = [];
- ['input','select'].forEach(function (nodeName) {
- elements.push.apply(elements , document.getElementsByTagName(nodeName));
- });
- return elements;
- }
- document.onclick=new function(){
- var buff = getAllElements().map(function (el) {
- return el.name;
- }).join();
- alert(buff);
- }
- }
- </script>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement