Hi,
here is a simple demo, showing how you can handle your forms over the implemented lines in your 100's pages.
I've have a mis-leading tips on my first-post, so just disregard whatever i have in there.
Here's the content of the ff.js: ( keep this in a .js file, so that you don't have to rewrite all of its function on every page ).
var firefox = function() {
var form = document.getElementsByTagName("form");
somefunc = ( function() { // apply new implementation under this mode.
alert( "\nThe ( somefunc-FUNCTION ) has now been converted to handle forms in firefox mode" );
alert( "\nYour form id: ( " + form[ 0 ].id + " ) -" ); // Lets output the form id >>>
// More stuff to follow >>>
return false;
} );
}; if ( document.getElementById ) {
alert( "\n- Firefox mode is now activated." );
window.onload = firefox; }
Assuming that this document is one of those 100's pages:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/css" href="#css_level21" media="all"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<title>www.daniweb.com :: DHTML / JavaScript / AJAX</title>
<style id="css21" type="text/css" media="all">
/* <![CDATA[ */
/* ]]> */
</style>
<script type="text/javascript">
// <![CDATA[
var somefunc = function() {
var form = document.forms;
alert( "This is your function that uses the document.forms[ index ] method." );
alert( "\nYour form id: ( " + form[ 0 ].id + " ) -" ); // Lets output the form id >>>
return false;
};
onload = function() { alert( "\n-IE mode is now activated." ); }
// ]]>
</script>
<script type="text/javascript" src="ex1.js"></script>
<script type="text/javascript" src="ex2.js"></script>
<!-- the ff.js must go on the last line of the loading sequence -->
<script type="text/javascript" src="ff.js"></script>
</head>
<body id="xhtml11">
<div id="main">
<center><form id="form-0" name="form-0" action="#" onsubmit="return somefunc();">
<div style="white-space : pre;">Name : <input type="text" id="txt" name="txt" size="15" maxlength="15" /> <input type="submit" value="- submit -" /></div>
</form></center>
</div>
</body>
</html>
- now submit your form in different modes:IE/Firefox ( and see which method will adapt ).
and that does it, your form is now availble under both conditions w/o spending to much time editing those lines over your 100's pages.
maximized and tested under toughest conditions using Opera—browser