Whats wrong with this code?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Grayslin
    New Member
    • Dec 2007
    • 3

    Whats wrong with this code?

    Got some code that works in IE, when I run in FF nothing happens. If I debug the code in venkman or firebug it magically works. But if I just run it in Firefox nothing happens?

    any Ideas?


    HTML Anchor tag
    [CODE=html]<a id="143066" name="143066" href="page.php" onclick="return trackclick(this .href, this.name, '143066 anchor text:page1');"> Page 1</a>[/CODE]

    tracker.js thats included in the head. using:
    <script type="text/javascript" src="js/tracker.js">
    </script>
    [CODE=javascript]function trackclick(url, aid, atxt) {
    if(document.ima ges){
    var img = new Image();
    var ClickTrack = "tracker.ph p";
    var image_src = ClickTrack+"?ur l="+url+"&aid=" +aid+"&atxt="+a txt+"&loc="+doc ument.location;
    img.src = image_src;
    }
    return true;
    }[/CODE]



    I know the PHP works. It works fine with IE. but here it is:
    [CODE=php]include($_SERVE R['DOCUMENT_ROOT']."includes/global.php");

    $ip = getenv("REMOTE_ ADDR");
    $userAgent = getenv("HTTP_US ER_AGENT");
    $clicktime = date("Y-m-d G:i:s T");
    $url = $url;
    $url_id = $aid;
    $anchor_text = $atxt;
    $loc = $loc;

    $data = array('ip' => $ip, 'useragent' => $userAgent, 'clicktime' => $clicktime, 'url' => $url, 'url_id' => $url_id, 'anchor_text' => $anchor_text, 'loc' => $loc);
    $db->loadModule('Ex tended');
    $db->extended->autoExecute('l ogger', $data, MDB2_AUTOQUERY_ INSERT);

    [/CODE]

    I know this is a FF compatibility issue, just can't figure it out.
    Last edited by gits; Dec 19 '07, 11:34 PM. Reason: fix code tags
  • drhowarddrfine
    Recognized Expert Expert
    • Sep 2006
    • 7434

    #2
    Possibly not the problem but id names may not begin with a number.

    Comment

    • Grayslin
      New Member
      • Dec 2007
      • 3

      #3
      Changed the anchor tag, now begins with a letter. Still doesn't work in FF.

      [HTML]<a id="nev003" name="nev003" href="page.php" onclick="return trackclick(this .href, this.name, 'nev003 anchor text:nev003');" >Page 1</a>[/HTML]

      Any other ideas?

      Comment

      • Grayslin
        New Member
        • Dec 2007
        • 3

        #4
        Anybody else have any ideas?

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          document.locati on should be document.URL or window.location .

          Comment

          Working...