php - Get DOM data with referring URL -
suppose have page following structure:
<li id="a"> <span class="some class">some content <a href="http://www.example.com">http://www.example.com</a> </span> </li>  <li id="b"> <span class="some class">some content <a href="http://www.example.com">http://www.example.com</a> </span> </li>  <li id="c"> <span class="some class">some content <a href="http://www.example.com">http://www.example.com</a> </span> </li>   is possible, php or js, grab list id (a,b,c) , append along referring url when person clicks on 1 of 3 links?
- need know 1 of 3 list tags click originated from
 - i don't have write access originating page
 
update
in light of revelation have no access original page, you've got no chance of finding out specific link clicked arrive @ page. can referrer document.referrer.
previous answer posterity
the following function capture click on link within container element specified id , add query string containing id of container element , url of current page url:
function modifylink(containerid) {     var el = document.getelementbyid(containerid);     el.onclick = function(evt) {         evt = evt || window.event;         var target = evt.target || evt.srcelement;         if (target.tagname == "a") {             window.location.href = target.href + "?id=" + encodeuricomponent(containerid) +                 "&referrer=" + encodeuricomponent(window.location.href);              return false; // cancel default link behaviour         }     }; }  modifylink("a"); modifylink("b"); modifylink("c");      
Comments
Post a Comment