views:

184

answers:

1

What could be going wrong here? The problem seems to be with the regex match statement. without it the alerts come, but as soon as I put it in everything goes quiet. Thanks so much! the wildcard is simply to help pinpoint the problem, it is NOT the objective, i do need regex.

window.addEventListener("load", function() { myExtension.init(); }, false);

var myExtension = {
  init: function() {
    var appcontent = document.getElementById("appcontent");   // browser
    if(appcontent)
      appcontent.addEventListener("DOMContentLoaded", myExtension.onPageLoad, true);
    var messagepane = document.getElementById("messagepane"); // mail
    if(messagepane)
      messagepane.addEventListener("load", function () { myExtension.onPageLoad(); }, true);
  },

  onPageLoad: function(aEvent) {
    var doc = aEvent.originalTarget; // doc is document that triggered "onload" event
    // do something with the loaded page.
    // doc.location is a Location object (see below for a link).
    // You can use it to make your code executed on certain pages only.

    var url = doc.location;  // i have also tried doc.location.href

    if (url.match(.*)) {alert( url );}

  }
}
+1  A: 

match takes a regexp object. A regexp object can be constructed with a literal of form /regex here/ (note the slashes).

With your code you should see a syntax error reported to the Error Console.

[edit] to be 100% clear, you need .match(/.*/) instead of .match(.*).

Nickolay
i didn't realize the slashes were part of it, thoought they were just <insert here> marks. thanks.
thanks for help
I considered posting this answer but I read the question at a 2nd grade level.
ChaosPandion