Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

লগিং

To follow this tutorial you'll need to have installed the SDK and learned the basics of cfx.

 ডম কনসোল অবজেক্ট  জাভাস্ক্রিপ্ট ডিবাগ করার জন্য ব্যবহৃত হয়। কারণ ডম অবজেক্ট গুলো মেইন অ্যাড-অন কোডে পাওয়া যায় না । SDK এর নিজেস্ব গ্লোবাল কনসোল অবজেক্ট আছে যার অধিকাংশ মেথড ডম কনসোল এর মত , যার মধ্যে আছে লগ এরর, ওয়ার্নিং অথবা ইনফরমেশনাল ম্যাসেজ। কনসোল এ এক্সেস করার জন্য আপনার কোন কিছুর প্রয়োজন()নেই। এটি automatically আপনার জন্য দেয়া আছে ।

The console.log() method prints an informational message:

console.log("Hello World");

Try it out:

  • create a new directory, and navigate to it
  • execute cfx init
  • open "lib/main.js" and add the line above
  • execute cfx run, then cfx run again

Firefox will start, and the following line will appear in the command window you used to execute cfx run:

info: Hello World!

console in Content Scripts

You can use the console in content scripts as well as in your main add-on code. The following add-on logs the HTML content of every tab the user loads, by calling console.log() inside a content script:

require("sdk/tabs").on("ready", function(tab) {
  tab.attach({
    contentScript: "console.log(document.body.innerHTML);"
  });
});

console Output

If you are running your add-on from the command line (for example, executing cfx run or cfx test) then the console's messages appear in the command shell you used.

If you've installed the add-on in Firefox then the messages appear in Firefox's Browser Console.

But note that by default, calls to console.log() will not result in any output in the Error Console for any installed add-ons: this includes add-ons installed using the Add-on Builder or using tools like the Extension Auto-installer.

See "Logging Levels" in the console reference documentation for more information on this.

Disabling strict mode

By default, cfx enables JavaScript strict mode, which will cause a lot of JavaScript warnings to be logged to the console. If this makes it harder to interpret logging output, you can disable strict mode by opening the file at python-lib/cuddlefish/prefs.py  and setting "javascript.options.strict" to False.

Learning More

For the complete console API, see its API reference.

ডকুমেন্ট ট্যাগ এবং অবদানকারী

 সর্বশেষ হালনাগাদ করেছেন: saima75,