Reputation: 1540
I have a function opening a new window, attached to a button:
<button onclick="newWin()">New Window</button>
This works fine but just the first time it is clicked. Following times, even when the opened window has been closed, I have this error:
TypeError: newWin is not a function
This is the JS function:
function newWin() {
newWindow= window.open('pan/newWin.html', 'Nueva ventana', 'toolbar=yes,location=no,resizable=no,width=600,height=820');}
Upvotes: 1
Views: 162
Reputation: 13382
You have two mistake:
In your case you just redefine global property newWin from function to object.
for solving you can rename it, or just use var keyword: var newWin = window.open(...)
Upvotes: 1
Reputation: 2343
Your are assigning some object to function variable.
First time on page load newWin()
will be loaded as function. After execution of function you are assigning some value to it .
Hence it is resulting in to error.
Upvotes: 1