How to make extension run on every page load - Mozilla

This is a discussion on How to make extension run on every page load - Mozilla ; Hi, I'm trying to write an extension for Firefox (I'm brand new at this), and I'd like my javascript code to execute every time I open a new page. I've tried to add the line: window.addEventListener("load", myfunction, false); in my ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: How to make extension run on every page load

  1. How to make extension run on every page load

    Hi, I'm trying to write an extension for Firefox (I'm brand new at
    this), and I'd like my javascript code to execute every time I open a
    new page. I've tried to add the line:

    window.addEventListener("load", myfunction, false);

    in my .js file (not inside any function) but it only executes the
    first time the browser is opened. If I navigate to another page, it
    doesn't get run again. I've also tried to replace 'window' with
    'document', but that doesn't help. Any ideas?

    Thanks for your help!

  2. Re: How to make extension run on every page load

    On Nov 20, 8:27*am, Karl wrote:
    > Hi, I'm trying to write an extension for Firefox (I'm brand new at
    > this), and I'd like my javascript code to execute every time I open a
    > new page. *I've tried to add the line:
    >
    > window.addEventListener("load", myfunction, false);
    >
    > in my .js file (not inside any function) but it only executes the
    > first time the browser is opened. *If I navigate to another page, it
    > doesn't get run again. *I've also tried to replace 'window' with
    > 'document', but that doesn't help. *Any ideas?
    >
    > Thanks for your help!


    maybe you should write your extension as a userChrome.js instead. It
    is more lightweighted and will execute every time a page loads

  3. Re: How to make extension run on every page load

    Thanks for the suggestion. I've been reading a lot and trying many
    different things, but nothing works. What I'd like to do is insert
    some code into Firefox in such a way that it gets executed every time
    a page is loaded. For example, I know that the Skype extension can do
    this. Every time I open a new webpage, it highlights all the phone
    numbers in it. I never have to click anywhere or do anything, the
    numbers just appear highlighted automatically. I've tried to figure
    out how they do it (that's where I got the window.addEventListener
    idea), but it's a huge piece of code, and maybe I went down the wrong
    track. Do you have any other ideas?

    Thanks again!

  4. Re: How to make extension run on every page load

    Aha! Finally found the trick. I was using addEventListener wrong.
    Here's a link to the magic code:

    https://developer.mozilla.org/en/Cod...ching_a_script

+ Reply to Thread