Jump to content

Firefox handles code different then other browsers


Bogey

Recommended Posts

Hi all,

 

Main page (tester.php) is this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml">	<head>		<title>TEST</title>		<?php		include ($_SERVER["DOCUMENT_ROOT"]."/0_head.php");		?>	</head>	<body>		<div class="entry" id="form_rebo">			<form id='form_verkoperAanmeld' method='GET'>				<fieldset>					<button tabindex='15' class='button radius right' id='buttonSend' onclick="aanmeldenTester('form_rebo')">TEST</button>				</fieldset>			</form>		</div>	</body></html>

js-files is this:

function aanmeldenTester(targetDiv){	alert ("aanmeldenTester");	document.getElementById('buttonSend').disabled = true;	run_xmlhttp();	xmlhttp.onreadystatechange=function() {		if (xmlhttp.readyState==4 && xmlhttp.status==200) {			document.getElementById(targetDiv).innerHTML=xmlhttp.responseText;		}	}	xmlhttp.open('GET', '/unsecure/aanmelden/db_addTempUserTEST.php', true);	xmlhttp.send();}

db_addTempUserTEST.php files is this:

<?phpecho "testTESTtest";?>

conclusions:

IE and Chrome gives me this:

- the alert box with message "aanmeldenTester"

- an empty page (tester.php) with: "testTESTtest"

 

FireFox gives me this:

- the alert box with message "aanmeldenTester"

- a page (teste.php) with the TEST-button

 

So how comes FF still gives me the TEST-button and IE and Chrome gives me the "testTESTtest"...

 

What IE and Chrome do I want, what FF does is not what I want...

 

Any clues?

Edited by Bogey
Link to comment
Share on other sites

I see the problem. Firefox, by default, assumes that a button element inside a form is a submit button.

 

Two things:

1. Since you're not actually using the form, don't use a <form> element, just put it in a <div> or another more suitable element. <form> elements are only for sending data to a new page. The lack of an action attribute makes the form submit to the same page.

2. If you insist on using a <form> element, add the attribute type="button" to your button to explicitly specify it's not a submit button.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...