Hi.
I've got this simple snippet
(function by icant.co.uk)
<!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">
<head>
<title>TwriTeLy</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
* {
margin:0px;
padding:0px
}
a:link, a:visited {
text-decoration : none;
font-weight:800;
}
a:hover {
text-decoration:underline;
font-weight:bold;
}
a:active {
text-decoration : none;
font-weight:800;
}
body {
text-align:center;
font-family:"Lucida Grande", "Trebuchet MS", "Bitstream Vera Sans", Verdana, Helvetica, sans-serif;
background-color:#B1D6B6;
color:#333333
}
div#container {
margin: 0 auto;
width:750px;
text-align:left;
border:2px solid #CCCCCC
}
div#header {
}
div#header h1 {
text-align:center;
}
div#login {
width:650px;
text-align:center;
}
div#footer {
}
div#footer h3 {
text-align:center
}
/* END MAIN */
/* FORM */
form {
width:550px;
margin: 0px auto;
text-align:left;
}
form label {
float:left;
width:250px;
margin-right:5px;
text-align:right;
}
form input {
width:250px;
}
br.frmClear {
clear:both
}
p.top {
text-align:center
}
p#register {
text-align:right
}
p#back {
text-align:right
}
p#error {
text-align:center
}
/* END FORM */
/* DOM */
.hide {
display:none
}
/* END DOM*/
</style>
<script language="JavaScript" type="text/JavaScript">
function Init()
{
if(!document.getElementById || !document.createTextNode){return;}
var frms = document.getElementsByTagName('form');
cssjs('add',frms[1],'hide');
var pr = document.getElementById('register');
addEvent(pr.firstChild,'click',Register,false);
var pb = document.getElementById('back');
addEvent(pb.firstChild,'click',pageBack,false);
}
function Register(e)
{
var frms = document.getElementsByTagName('form');
cssjs('add',frms[0],'hide');
cssjs('remove',frms[1],'hide');
cancelClick(e);
}
function pageBack()
{
window.history.back();
}
function cssjs(a,o,c1,c2)
{
switch (a)
{
case 'swap':
o.className=!cssjs('check',o,c1)?o.className.replace(c2,c1):o.className.replace(c1,c2);
break;
case 'add':
if(!cssjs('check',o,c1)){o.className+=o.className?' '+c1:c1;}
break;
case 'remove':
var rep=o.className.match(' '+c1)?' '+c1:c1;
o.className=o.className.replace(rep,'');
break;
case 'check':
return new RegExp("(^|\\s)" + c1 + "(\\s|$)").test(o.className)
break;
}
}
function addEvent(elm, evType, fn, useCapture)
{
if (elm.addEventListener)
{
elm.addEventListener(evType, fn, useCapture);
return true;
} else if (elm.attachEvent) {
var r = elm.attachEvent('on' + evType, fn);
return r;
} else {
elm['on' + evType] = fn;
}
}
function cancelClick(e)
{
if (window.event)
{
window.event.cancelBubble = true;
window.event.returnValue = false;
return;
}
if (e)
{
e.stopPropagation();
e.preventDefault();
}
};
addEvent(window,'load',Init, false);
</script>
</head>
<body>
<div id="container">
<div id="header">
<h1>TwriTeLy</h1>
</div>
<div id="login">
<form name="frmLogin" action="" method="post">
<p class="top">Login</p>
<input type="hidden" name="checherLogin" value="1165224061" />
<input type="hidden" name="poster" value="yes" />
<label>Username : </label>
<input type="text" name="username" value="" maxlength="32" /><br class="frmClear" />
<label>Password : </label>
<input type="password" name="password" value="" maxlength="32" /><br class="frmClear" />
<p id="error">Invalid</p>
<label> </label>
<input type="submit" name="login" value="Login" />
<p id="register"><a href="loginXHTML.php">Register</a></p>
</form>
<form name="frmRegister" action="" method="post">
<p class="top">Register</p>
<input type="hidden" name="checherLogin" value="1165224061" />
<input type="hidden" name="poster" value="yes" />
<label>Username : </label>
<input type="text" name="username" value="" maxlength="32" /><br class="frmClear" />
<label>Password : </label>
<input type="password" name="password" value="" maxlength="32" /><br class="frmClear" />
<label>Email : </label>
<input type="text" name="email" value="" maxlength="32" /><br class="frmClear" />
<label> </label>
<input type="submit" name="register" value="Register" />
<p id="back"><a href="loginXHTML.php"><< Back</a></p>
</form>
</div>
<div id="footer"><h3>By Whisher</h5></div>
</div>
</body>
</html>
Well it works fine with IE , Mozilla and FF
but window.history.back() doesn't work with
Opera 9.
Do you know why ?
Do you know any workaround ?
Thanks in advance 😉
Bye.