javascript - Click a link in Safari that is inside a table -


essentially have link inside of huge table in safari. want click row 2 column 1. name of link changes inside cell.

here html http://pastebin.com/uuwffcyg

i put visual marker in code want click. in example search "1222" , pull right up.

basically once link clicked opens window can hack around , use system events tab , select stuff , reload page , again.

bonus if can tell me how check text in next column. row 2 column 2. if says "open" click on link in cell left.

full disclosure have written applescript program this, using python clicks governed screen coordinates, if resolution changes or add monitor breaks program. it's hacky works. looking more native.

any appreciated! brandon

so automatically want see if there link in row 2, column 1 of table , click on it?

<script language="javascript"> function clicklinksintable(i) {     // check if link exists in row     if (!document.getelementsbytagname("tr")[i+1].getelementsbytagname("td")[0].getelementsbytagname("a")[0] || !document.getelementsbytagname("tr")[i+1].getelementsbytagname("td")[1]) {         // fail silently.     } else {         // check if next column right contains word "open" .         if (document.getelementsbytagname("tr")[i+1].getelementsbytagname("td")[1].innerhtml.tolowercase().indexof("open") != -1) {             // row (tr) user wants (the first row never contains link, add 1 avoid being problem)             // first column (td) in row, , first (probably only) link in column.             link = document.getelementsbytagname("tr")[i+1].getelementsbytagname("td")[0].getelementsbytagname("a")[0];             // then... click on it! while we're focussed on safari, it's support other browsers well,             // in case want use code again elsewhere.             // firefox             if (document.createevent) {                 var event = document.createevent("mouseevents");                 event.initevent("click", true, true);                 link.dispatchevent(event);             }             // ie             else if (link.click) {                 link.click();             }         }     } } // call function made earlier. value in brackets row number of link want click. // click link in row two, column one. clicklinksintable(0); // click link in row five, column one. //clicklinksintable(3); </script> 

add after table.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -