Логин:

Пароль:

Форумы
Общие вопросы
Document Object Model
Обсуждаем конференцию
Web Usability (test)

Общие вопросы

Позиционирование объекта относительно другого объекта

сделал так

<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
.sAgent = navigator.userAgent;
.nAgent1 = navigator.appName;
.if (nAgent1 = "Microsoft Internet Explorer"){
.bname=1
.}
.else {
.bname=2
.}
.if (bname > 2)
{
//document.writeln ( "<LAYER NAME = 'pechat' VISIBILITY = 'hide' id= 'pechat'>" );
//document.writeln ( "<img SRC='/images/pechat.gif' ALT WIDTH='149' HEIGHT='144' > " );
//document.writeln ( "</LAYER>" );
//document.writeln ( "<LAYER NAME = 'rospis' VISIBILITY = 'hide' id= 'rospis'>" );
//document.writeln ( "<img SRC='/images/rospis.gif' ALT WIDTH='149' HEIGHT='144' > " );
//document.writeln ( "</LAYER>" );
}
else {
document.writeln ( "<div style='position:absolute; width:149; height:144;' id='pechat'>" );
document.writeln ( "<img SRC='/images/pechat.gif' WIDTH='149' HEIGHT='144'>" );
document.writeln ( "</div>" );
document.writeln ( "<div style='position:absolute; width:91; height:74;' id='rospis'>" );
document.writeln ( "<img SRC='/images/rospis.gif' WIDTH='91' HEIGHT='74' >" );
document.writeln ( "</div>" );
}
.bIsMac = sAgent.indexOf("Mac") > -1;.
.bIsIE = sAgent.indexOf("MSIE") > -1;
.bIsIE4 = sAgent.indexOf("IE 4") > -1;
.bIsIE5 = sAgent.indexOf("IE 5") > -1;
.bIsNav = sAgent.indexOf("Mozilla") > -1 && !bIsIE;
.bDoesAll = (bIsIE4 || bIsIE5) && !bIsMac;
.
function window_onload() {

var Left1 = relPosX('pic_pchatx');
var top1 = relPosY('pic_pchatx');
var Left2 = relPosX('director');
var top2 = relPosY('director');
//document.layers.pechat.moveTo(500, 500);
//lav_div('pechat');
window.pechat.style.posTop = top1-90;
window.pechat.style.posLeft = Left1-57;
window.rospis.style.posTop = top2+30;
window.rospis.style.posLeft = Left2 -30;
setTimeout("window_onload()",1);


}
function lav_div(which) {

if (bname > 2) {
document.layers[which].moveToAbsolute(500, 500);

//alert(document.layers[which].Layer_Name );
//window.layers["pechat"].moveToAbsolute(500, 500);
//window.layers[pechat].moveToAbsolute(500, 500);
}
else {
//top1=window.pic_pchatx.offsetTop;
//Left1=window.pic_pchatx.offsetLeft;
//alert(Left1);

}

}

function relPosX(which) {
if (bname > 2) {
return document.layers[which].pageX;
}
else {
var elem = document.getElementById(which);
var pos = elem.offsetLeft;
while (elem.offsetParent != null) {
elem = elem.offsetParent;
pos += elem.offsetLeft;
if (elem.tagName == 'BODY') break;
} return pos;
}
}
function relPosY(which) {
if (bname > 2) {
return document.layers[which].pageX;
} else {
var elem = document.getElementById(which);
var pos = elem.offsetTop;
while (elem.offsetParent != null) {
elem = elem.offsetParent;
pos += elem.offsetTop;
if (elem.tagName == 'BODY') break;
} return pos;
}
}

function pic_pchatx_onclick() {
window.pechat.style.top = 150;
}

//-->
</SCRIPT>
Спосиба за функцию и за стотью
С нетскепом беда
document.layers[which].moveToAbsolute(500, 500);
не работает
в эксплоуре при печате плывут слои если больше 1 стр.
не хочется делать одну большую картинку :-((((
СообщениеАвторДата
ldv07.10.2001 17:09
Leechy07.10.2001 17:50
ldv08.10.2001 16:05
Leechy10.10.2001 14:56