By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,036 Members | 978 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,036 IT Pros & Developers. It's quick & easy.

Detecting clicks in frames....

manuelgk
P: 54
Hello everybody!!, as you see I have been trying the "urls-click detector" in my example pages and in other pages of the Web. Yesterday, I downloaded the JDK and as you know it has its own tutorial Web page so I tried to put my script into this page but it had no effect!! :S. The index page calls other pages with frames. My question: is it possible to detect a click into the frames?
Here is my script code, I already change (for people who had seen this before) some lines:
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.  
  3.       window.onload=function() {
  4.               els=document.body.getElementsByTagName('*');
  5.                 for(c=0;c<els.length;c++){
  6.                   els[c].onclick=function(){
  7.                    getOnclicks(this);
  8.                   }
  9.                  }
  10.          }
  11.  
  12.              function getOnclicks(el) {
  13.              cadena=new String("?COLAB_CLICK=YES");
  14.              var url=String(el.getAttribute('href'));
  15.              if (el.tagName=="A"){
  16.                  el.href=el.href + cadena;
  17.                  }
  18.  
  19.              }
  20.  
  21.      </script>
Thanks everybody
Oct 9 '07 #1
Share this Question
Share on Google+
3 Replies


iam_clint
Expert 100+
P: 1,208
You will need to loop through document.frames
Oct 9 '07 #2

manuelgk
P: 54
[Ok so, what I need to is something like a condition to take the document's frames and the href if I I want to conserve my original code right?.
Kind regards
Oct 11 '07 #3

manuelgk
P: 54
Hi everyone,
I tried to make what you told me to do, however when I changed the line "document.body" with the line "document.frames" it did not work as I expected :S. My conclusions for this problem are:
-> Web pages containing frames calls other pages from somewhere else
-> Some of these Web pages act like an "Index" where the other pages are including (Pages with frames).
-> For this 2 reasons, with my code I can not access the clicks into the pages contained inside the frames, so I put my script into the loaded pages in the frames and it works well allways with hyperlinks which go to another Web page and not into the same page (weird!!!:S).

I do not know if it is true or if there is a way to adapt my code to detect the clicks in frames, and knowing into which frame should the page be presented (that is, which is the "target" frame).
I hope you can give me better advices for this problem.
Thanks a lot!!!
Oct 11 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.