Reputation: 639
I am creating a Chrome extension where you click on a button which launches an HTML page you created before. This is my button:
var btn = document.createElement("BUTTON");
var t = document.createTextNode("Click Me");
btn.addEventListener("click", popUpWindow);
btn.appendChild(t);
document.getElementsByClassName("text")[0].appendChild(btn);
This is my function:
function popUpWindow() {
window.open("window-child.html", "Accept", "width=400,height=300,0,status=0,")
}
This is my html page
<html>
<head>
<title>Demo of child window</title>
</head>
<body>
This is child window
</body>
</html>
Inside the manifest.json I added:
"web_accessible_resources": [ "window-child.html" ]
But when I click on the button it redirects me to https://www.linkedin.com/window-child.html, which gives:
404 Page Not Found
Upvotes: 1
Views: 1581
Reputation: 7156
Use chrome.extension.getURL()
to generate URL of the form
chrome-extension://[PACKAGE ID]/[PATH]
Code:
var url = chrome.extension.getURL("window-child.html");
window.open(url);
Upvotes: 1
Reputation: 918
Use "_blank" target name as second parameter of window.open :
window.open("window-child.html","_blank", "width=400,height=300,0,status=0")
Upvotes: 0