Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jul 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    JS Code Question

    Hey guys, I have a question about a snippet of JS that I found.

    Does the JS (or can JS) code allow for tracking whether you've 'clicked' out of the screen to go, say, to another webpage or open another program?

    I would like to try and incorporate some sort of tracking that could identify whether a user has clicked out of the active webpage and onto another. Does this code provide for that?

    Thank you

    Code:
      <script language="javascript">
    <!--
    var playButton =  null;
    
    function playIt(itemNum, playBtn, snd, len)
    { playButton = playBtn;
      playButton.className = 'played';
      playButton.innerHTML = 'Listen...';
      var obj = document.getElementById('sndObj');
      obj.innerHTML = '<embed id="ply" src="' + snd + '" hidden="true" autostart="true">';
      window.setTimeout(donePlaying, len);
    }
    
    function donePlaying()
    { playButton.innerHTML = 'Mark the letter of the choice that answers the question.';
      var hs = document.getElementById('hs');
      hs.className = 'vis';
    }
    
    function mc(obj,itm)
    { var ans = obj.innerHTML;
      for (var i = 0; i < ans.length; ++i)
      { var ch = ans.substr(i,1);
        if (ch < 'A' || ch > 'E') continue;
        ans = ch;
        break;
      }
      document.forms.frm.ansr.value = ans;
      var spans = document.getElementsByTagName("span");
      for (i = 0; i < spans.length; ++i)
      { if (spans[i] === obj)
        { spans[i].style.color = "white";
          spans[i].style.backgroundColor = "blue";
        }
        else
        { spans[i].style.color = "blue";
          spans[i].style.backgroundColor = "#d0d0d0";
        }
      }
    }
    -->
      </script>

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,239
    Thanks
    203
    Thanked 2,554 Times in 2,532 Posts
    Quote Originally Posted by bound4h View Post
    Can JS code allow for tracking whether you've 'clicked' out of the screen to go, say, to another webpage or open another program?
    Answer - no.

    Are you trying to detect if the user has visited Google in an attempt to find the answer to the questions?

    <script language=javascript> is long deprecated and obsolete. Use <script type = "text/javascript"> instead. The <!-- and //--> tags have not been necessary since IE3 and invariably indicate ancient code.


    It is your responsibility to die() if necessary….. - PHP Manual
    Last edited by Philip M; 07-23-2009 at 08:53 AM.

  • #3
    New to the CF scene
    Join Date
    Jul 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, Philip, I want to determine whether the user has looked up the question outside of the current browser window. And you are saying that this is not possible, correct?

    Thank you for your help.

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,239
    Thanks
    203
    Thanked 2,554 Times in 2,532 Posts
    Quote Originally Posted by bound4h View Post
    Yes, Philip, I want to determine whether the user has looked up the question outside of the current browser window. And you are saying that this is not possible, correct?

    Thank you for your help.
    Yes, not possible.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •