Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

197
Vistas
swal is not rendered in context menu of an chrome extension

I want to use SweetAlert for alert box in my chrome extension. SweetAlert has to be shown when clicked in context menu. I have attached the sweetalert code in background scripts property inside manifest.json. I also used the css in content_scripts. Though default alert is showing but SweetAlert is not showing.

Here is the code for manifest.json

{
  "manifest_version": 2,
  "name": "Detect Sentiment",
  "version": "1.0",
  "description": "A extension which can detect sentiment",
  "icons": {
    "128": "icon128.png",
    "48": "icon48.png",
    "16": "icon16.png"
  },
  "browser_action": {
    "default_icon": "icon16.png",
    "default_popup": "popup.html"
  },
  "background": {
    "scripts": ["eventPage.js", "sweetalert.min.js"],
    "css": ["sweetalert.css"],
    "persistent": true
  },
  "permissions": ["activeTab", "notifications", "contextMenus"]
}

Here is the code for eventPage.js

var contextMenuItem = {
  id: "detectSentiment",
  title: "Detect Sentiment",
  contexts: ["selection"],
};
chrome.contextMenus.create(contextMenuItem);

chrome.contextMenus.onClicked.addListener(function (clickData) {
  if (clickData.menuItemId == "detectSentiment" && clickData.selectionText) {
    console.log(clickData.selectionText);
    swal("Hello");
    alert(clickData.selectionText);
  }
});

How can I fix this problem?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda