Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

131
Views
iFrame se carga automáticamente cada vez que se carga mi extensión de Chrome

así que soy un principiante y comencé a hacer una extensión de Chrome solo por diversión. Es una extensión básica que crea un elemento iframe en cualquier página. He agregado el detector de eventos onClick en mi código para activar el iFrame cada vez que se hace clic en el logotipo de la extensión. Pero por alguna razón, cada vez que abro un sitio nuevo, el iFrame se carga automáticamente. Se vuelve a cargar cuando presiono el ícono de la extensión de Chrome, pero no puedo hacer que deje de aparecer cada vez que se visita un nuevo sitio. Aquí está mi código. ¡Cualquier ayuda sería apreciada!

manifiesto.json

 { "name": "Sample Extension", "action": {}, "permissions": ["activeTab", "scripting","tabs","clipboardRead", "clipboardWrite"], "background": { "service_worker": "background.js" }, "version": "1", "manifest_version": 3, "content_scripts": [{ "js": ["contentscript.js"], "matches": ["<all_urls>"], "all_frames": true }], "web_accessible_resources": [ { "resources": [ "frame.html" ], "matches": ["<all_urls>"] } ] }

contentscript.js

 var extensionOrigin = 'chrome-extension://' + chrome.runtime.id; if (!location.ancestorOrigins.contains(extensionOrigin)) { var iframe = document.createElement('iframe'); iframe.src = chrome.runtime.getURL('frame.html'); iframe.style.cssText = 'position:fixed;top:25px ;left:25px;display:block;' + 'width:calc(100% - 50px);height:calc(100vh - 50px);z-index:9999; background: none; border: none; border-radius: 10px'; document.body.appendChild(iframe); }

fondo.js

 chrome.action.onClicked.addListener((tab,tabId) => { chrome.scripting.executeScript({ files: ["contentscript.js"], target: {tabId: tab.id} }) });

marco.html

 <style> html, body, iframe, h2 { margin: 0; border: 0; padding: 0; display: block; width: 100vw; height: 100vh; background: none; color: black; } h2 { height: 50px; font-size: 20px; } iframe { height: 100vh; } </style> <iframe src="https://www.youtube.com/"></iframe>
about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!