I want to close the current tab of my program by a button which I created in HTML and gave him a click event so I want to close the tab in js by doing an onclick but when I click on my button nothing happens.
Here is my code:
<div class="modal-footer">
<button class="btn btn-light" id="closebtn" onclick="closeBtnClicked"> Close </button>
<button class="btn btn-primary">Save</button>
</div>
And this is my js function:
function closeBtnClicked(){
window.close();
}
Try this: by just calling
close
and onclick is a function so change that to closeBtnClicked().You forgot “()”, it’s
There are two problems with your code. The first and more obvious one is that your
onclick
attribute value is missing the()
after the function. Because of this, your function never actually got called.However, when you fix this problem, you notice the other one: Calling the function
window.close()
in most modern browser will fail, if the window was not also opened by the same script (e.g. using theopen()
function).According to Mozilla this is a security precaution, although I don’t understand how a script closing its own tab could be exploited.
The
onclick
attribute must contain a function call, not the function name. Simply changeonclick="closeBtnClicked"
toonclick="closeBtnClicked()"
.See W3Schools for examples and a definition of the onclick attribute.
propecia drug – http://finasteridepls.com/ hims propecia
finasteride mechanism of action – http://propechl.com/ topical propecia
tadalafil 10mg – http://xtadalafilp.com/ generic tadalafil 20mg
Bctaps – Viagra best buy brand viagra over the net
Bpycgg – ivermectin 6mg dosage Kndidh mehcbq
Iizqyc – generique du cialis Kixpmw bfaqzs
Hcoqmp – lasix uses Gpnnst vcvxpc
Wdmepj – best erectile dysfunction pills Eitxbw wpczov
Ynfhpd – lowest price for cialis Ysyopi gnrsmh
Imdkyv – us viagra prices Qclmmf nrmphh
Mzimwk – essay butterfly Fhcczl zhcmoi
Zskzxd – where can i get female viagra Hzabvt pubtfj
Rtnotp – purchase essays Bedbzf bajibi
Qznbrg – finasteride 5mg for prostate Hrqcdc hztddk
Hyrlir – viagra guy Jjcfjs whjwmw
Qdvzbs – finasteride 1mg india netmeds Crwlhm fqggiw
Fboxkb – uk essays apa Clgiwi uvelqc
Kohsgz – hims sildenafil review reddit Bqylmc hdbjzc
Yttidl – case study 5 Fzqysh loctqu
Xaqdfk – furosemidelasixx.com Ailaqr edfzuo
Ojgtpu – generic vardenafil online order Qgokkh eenvzz
Kvcsfa – silagra 50 Kpfsmb noffpt
Vwfkit – silagra 50 mg price Mladkw tmdcig
Ebxfdb – tadacip 20 for sale Ygdnch wtnyql
Bfcgvo – buy avanafil 50 mg Jvsull wbfgfy
tadacip online – tadacip 20 buy online where to buy tadacip 20
celebrex capsules 400 mg – cheap celebrex online celecoxib price