|
|
|
| Есть скрипт, для скрытия и отображения объектов по событию:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<script language="javascript">
function getObject(obj)
{
var theObj
if (document.layers) {
if (typeof obj == "string") return document.layers(obj)
else return obj
}
if (document.all) {
if (typeof obj == "string")
{
if (document.all(obj)!=null) return document.all(obj).style;
else return null;
}
else return obj.style
}
if (document.getElementByld)
{
if (typeof obj == "string")
return document.getElementByld(obj).style
else return obj.style
}
return null
}
// Функция для отображения объектов
function show (obj)
{
var theObj = getObject(obj);
if (typeof theObj.visibility != "undefined")
theObj.visibility = "visible"
if (typeof theObj.display != "undefined") theObj.display = "block"
}
// Функция для скрытия объектов
function hide (obj)
{
var theObj = getObject(obj);
if (typeof theObj.visibility != "undefined")
theObj.visibility = "hidden"
if (typeof theObj.display != "undefined") theObj.display = "none"
}
// Смена отображаемых и визуальных блоков
function change(id)
{
if (id==1)
{
show("block1");
hide("block2");
}
else
{
show("block2");
hide("block1");
}
}
</script>
</head>
<body>
<form method="post" action="#">
<input type="radio" name="rb" value="1" onClick="change(1)">Блок 1
<input type="radio" name="rb" value="2" onClick="change(2)">Блок 2
</form>
<div id="block1">
Содержимое 1 блока
</div>
<div id="block2">
Содержимое 2 блока
</div>
</body>
</html>
|
Проблема в том, что данный скрипт не работает в Мозиле и последней версии Оперы!
Кто нибудь может усовершенствовать его, чтобы он работал во всех браузерах или может есть какой-нибудь альтернатывный вариант?
Заранее спасибо | |
|
|