I have some troubles with confirm dialog not working with Firefox, but working with Chrome.
html code looks like this:
<input type="submit" name="Odjava" value="Remove selected link" onclick="return odjava(somelink,'Do you really want to remove ')"/>
javascript code looks like this:
function odjava(link,text)
{
if(link=="" || text=="")
return false;
return confirm(text + link + " ?");
}
With Chrome, everything is ok – onClick generates “confirm” dialog, and if user answer with “yes”, form is submitted, otherwise it’s not. Firefox doesen’t show “confirm” dialog, it just submits the form.
Why’s that? What am i doing wrong?
****EDIT:
I got it! I just changed my javascript to look like this:
function odjava(text)
{
var linkovi = document.getElementById('linkovi');
link = linkovi.options[linkovi.selectedIndex].text
if(link=="" || text=="")
return false;
return confirm(text + link + " ?");
}
and it’s working. It turn out that Chrome can find element in document even without document.getElementById, FF can’t (won’t)!
Is
somelinkdefined safely in both Firefox and Chrome?When I try your code it works successfully in both FF and Chrome if
someLinkis defined, and fails to work as you describe in both if it is not defined.