I've been creating a chrome extension that splits my new tab pages into 2 frames so I can try to load 2 different URLs. Right now I've started off simple, but I can't get them to load as intended. Here's the code:
Background.html
<!DOCTYPE html>
<html>
<head>
<title>2 Pages</title>
</head>
<frameset cols="*,*">
<frame src="left.html" name="left">
<frame src="right.html" name="right">
</frameset>
<script type="text/javascript" src="script.js"></script>
</html>
Left and Right
<!DOCTYPE html>
<html>
<body>
<input type="button" value="Load new document" id="loader">
</body>
</html>
Script.js
document.addEventListener('DOMContentLoaded', function() {
document.getElementById("loader").addEventListener.("click", loadUrl);
});
function loadUrl(){
window.location = 'http://www.w3schools.com';
return false;
}
I've tried loading the js before and after the frames, and also inside each frame. when I click the input button, nothing happens. I inspected the page, and it shows no event listeners present, and no errors in the console. Though, If I try to cut out the frameset
and try just loading a page with one button, I get an error that reads Uncaught SyntaxError: Unexpected token (
for line 2 of script.js
. Is there something I'm missing? Thanks.