I am making a chrome extension and I have multiple buttons which open different tabs. Unfortunately for some reason when I click the Seqta button it opens the tab 3 times and with the maths book it opens the tab twice. I'm not sure what is wrong but I have put the html and javascript below.
HTML
<!DOCTYPE html>
<html>
<head>
<style>
body{
background-color: #263238;
width: 300px;
height: 500px;
}
</style>
</head>
<body>
<div id="buttons">
<div id="buttonDivSEQTA">
<button type="button" class="button" id="seqta" >Seqta</button>
<script src="popup.js"></script>
</div>
<div id="buttonDivMATH">
<button type="button" class="button" id="maths">Maths Textbook</button>
<script src="popup.js"></script>
</div>
<div id="buttonDivHASS">
<button type="button" class="button" id="hass">HASS Textbook</button>
<script src="popup.js"></script>
</div>
</div>
</body>
</html>
Javascript
var button = document.getElementById("seqta");
button.addEventListener("click", function(){
chrome.tabs.create({url:"https://learn.bcgs.wa.edu.au"});
});
var button = document.getElementById("maths");
button.addEventListener("click", function(){
chrome.tabs.create({url:"https://jacplus.com.au"});
});
var button = document.getElementById("hass");
button.addEventListener("click", function(){
chrome.tabs.create({url:"http://www.pearsonplaces.com.au/User_Login.aspx"});
});
It would be great if someone could help me out
`.
– wOxxOm Sep 18 '18 at 06:27