When I try to push a url into an array then window.open() all urls in the array, I get a null error. I believe this is because the url is not being properly placed in the array to start. What am I doing wrong? Thanks.
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<form>
Series Name:
<input type="text"
name="series1name"
id="seriesname"/>
<br/>
Series Link:
<input type="text"
name="series1link"
id="serieslink"/>
</form>
<div>
<button onclick="AddSeries()">Add A New Series </button>
</div>
<div>
<button onclick="OpenSeries()">Open Incomplete Series </button>
</div>
</body>
<script type="text/javascript">
var urlArray = [];
function AddSeries() {
var url = document.getElementById('serieslink');
urlArray.push(url);
}
function OpenSeries() {
for (url in urlArray) {
alert(url.constructor === Array);
window.open(url, '_blank');
}
}
</script>
</html>
I'm sorry if the error is obvious, I am somewhat new to coding and so I'm sure this code isn't perfect by any means. Thank you in advance.
Thank you everyone, a combination of two responses got my code to work the way I wanted it to.
` and `
– Sebastian Simon Aug 26 '16 at 19:57