0

I have an extension in which when I click on the icon, a popup opens. The user will not press any buttons within the extension page, the page should by default be the Google page due to the script mentioned.

The code for the pop up (in HTML) is:

    <html>
<head>
    <style type="text/css">
    body {width:780; height:580;}
    </style>
</head>
<script>
    var value_raw2 = "https://www.google.com/";
document.getElementById("MyFrame").src = value_raw2 + ReturnURL();
</script>
<body>
    <iframe id="MyFrame" src = "" width="100%" height="100%" frameborder="0">
    </iframe>
</body>
</html>

Basically, I want the pop-up to open Google.com and not a blank page by implementing the script. However, it seems to be ignoring the script. This is a basic case which I will be refining later to dynamically change URL to anything at all at random.

Ansh
  • 165
  • 1
  • 1
  • 10
  • 1
    I think the document has not been fully parsed when the `script` runs. Put it at the bottom of the body instead. (or can you put it in a separate file and give it the `defer` attribute in an extension?) – CertainPerformance May 13 '18 at 09:14
  • Possible duplicate of [onClick within Chrome Extension not working](https://stackoverflow.com/questions/13591983/onclick-within-chrome-extension-not-working) – wOxxOm May 13 '18 at 09:15
  • Don't use inline code in extension pages, see the linked topic for explanation and solutions. Also, since the popup is a totally separate page, it has its own devtools which you can access by inspecting the popup window via right-click context menu. There you'll see the error I'm talking about. – wOxxOm May 13 '18 at 09:15
  • @CertainPerformance Defer doesn't do the trick unfortunately. – Ansh May 13 '18 at 09:46
  • @wOxxOm Anyway to run Javascripts in that case? – Ansh May 13 '18 at 10:58
  • Simply use a separate js file, the linked topic explains it all in detail. – wOxxOm May 13 '18 at 11:23

0 Answers0