html - JavaScript similar functions not working -


i need make 3 buttons each open similar windows.

in index.html follows

<li><button type="button" onclick="openbeep()">beep</button></li> <li><button type="button" onclick="openflash()">flash</button></li> <li><button type="button" onclick="window.open()">indexing</button></li> 

my openbeep()

function openbeep() {   var w = window.open(''),     button = w.document.createelement('button');   button.innerhtml = 'start test';    button.addeventlistener('click', function () {     w.alert('!');   });    var container = w.document.createelement('div');   container.id = 'buttonparent';     w.document.body.appendchild(container);   container.appendchild(button); } 

that script works fine, if replace onclicks openbeep, open new windows.. openflash nothing despite being identical.

function openflash() {   var x = window.open(''),     button = x.document.createelement('button');   button.innerhtml = 'start test';    button.addeventlistener('click', function () {     x.alert('!');   });    var container = x.document.createelement('div');   container.id = 'buttonparent';     x.document.body.appendchild(container);   container.appendchild(button); } 

quick tip starting javascript programmers: make sure have inspector / developer tools open. in browsers open f12.

then in console monitor errors. problem (which solved ;-) you'd see error saying function not found.


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -