Firefox Extension: Getting JavaScript Variable From Web Document

Posted on 2007-10-03
Last Modified: 2013-12-07
Hi all,
I'm trying to find out how to access a JavaScript variable in a web document, from within a Firefox extension. So if I open a document that looks like this:

<script type="text/javascript">
var my_message = 'Hello World!';

How can I get the value of my_message from my Firefox extension?
Question by:headzoo
    LVL 23

    Expert Comment



    Author Comment

    That doesn't seem to work. I'm using the function:

    function Test_Function()

    That is rigged up to a button in a Firefox toolbar. I press the button after the page is fully loaded, and it just shows up as "undefined".
    LVL 23

    Accepted Solution

    sorry my good fellow...
    try this:


    Author Comment

    Fantastic! Worked like a charm.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Suggested Solutions

    Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
    Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
    This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now