Для того чтобы правильно понять мою мысль, прошу посмотреть на шапку моего форума. http://www.photoimpact.0pk.ru Как видите, рядом с рекламным баннером установлен баннер самого форума. Смотрится лучше чем пустое место но беда в том, что это не баннер. Вернее не совсем баннер. Он не кликабельный. Это всего лишь фрагмент фоновой картинки. У меня сайт и два форума. И задумал я установить на этом месте прокрутку своих баннеров. Я порезал эту фоновую картинку на таблицу с BORDER="0", причём одна из ячеек обрамляет баннер на этой картинке (т.е. имеет стандартные размеры баннера) и ввёл в неё скрипт прокрутки баннеров конечно же указав путь к самим баннерам. Проверил в браузере,-всё работает чётко.
Вот код без адресов картинок так как путь указывал на баннеры хронящиеся в компе.
<SCRIPT> <!-- var htmlNBSP = " "; var LinkList = new Array; var ImageNameMap = new Array; var Timer = new Array; function NSMouseCallback(name,callback) { this.name = name; this.callback = callback; } function AddNSMouseCapture(srclayer,name,down_callback,up_callback) { if (null == srclayer.captureEvents) return; //Local var callbacklist; var i; //Capture if (null != srclayer.down_callback) srclayer.releaseEvents(Event.MOUSEDOWN); if (null != srclayer.up_callback) srclayer.releaseEvents(Event.MOUSEUP); srclayer.captureEvents(Event.MOUSEDOWN); srclayer.captureEvents(Event.MOUSEUP); //Init if (null == srclayer.down_callback) srclayer.down_callback = new Array; if (null == srclayer.up_callback) srclayer.up_callback = new Array; //Add Callback for (i = 0; i < srclayer.down_callback.length; i++) { if (srclayer.down_callback[i].name == name) { srclayer.down_callback[i].callback = down_callback; break; } } if (i == srclayer.down_callback.length) srclayer.down_callback[srclayer.down_callback.length] = new NSMouseCallback(name,down_callback); for (i = 0; i < srclayer.up_callback.length; i++) { if (srclayer.up_callback[i].name == name) { srclayer.up_callback[i].callback = up_callback; break; } } if (i == srclayer.up_callback.length) srclayer.up_callback[srclayer.up_callback.length] = new NSMouseCallback(name,up_callback); //Set Handle callbacklist = ""; for (i = 0 ; i < srclayer.down_callback.length; i++) callbacklist = callbacklist + srclayer.down_callback[i].callback; srclayer.onmousedown = new Function("event",callbacklist); callbacklist = ""; for (i = 0 ; i < srclayer.up_callback.length; i++) callbacklist = callbacklist + srclayer.up_callback[i].callback; srclayer.onmouseup = new Function("event",callbacklist); } function RemoveNSMouseCapture(srclayer,name) { if (null == srclayer.releaseEvents) return; srclayer.releaseEvents(Event.MOUSEDOWN); srclayer.releaseEvents(Event.MOUSEUP); srclayer.down_callback = null; srclayer.up_callback = null; } function IsPrefixWith(szSrc,start,szPrefix) { if ("" == szSrc || "" == szPrefix) return false; if (0 == szSrc.length || 0 == szPrefix.length) return false; vari; for(i = 0; 0 != szSrc.charAt(start + i) && 0 != szPrefix.charAt(i); i++) { if (szSrc.charAt(start + i) != szPrefix.charAt(i)) break; } return 0 == szPrefix.charAt(i); } function IsPrefixSpecialChar(szSrc,start) { if ("" == szSrc || 0 == szSrc.length) return false; return '&' == szSrc.charAt(start); } function GetPrefixSpecialCharLen(szSrc,start) { // Gaurd if (0 == szSrc.length || '&' != szSrc.charAt(start)) return 0; // Init var Len = 0 , i; for(i = 0; 0 != szSrc.charAt(i); i++) { if (';' == szSrc.charAt(start + i)) { Len = i + 1; break; } } // Return return Len; } function FindTopDoc(curWindow) { if (curWindow == null) return null; if ((curWindow.parent != null) && (curWindow.parent != curWindow)) { return this.FindTopDoc(curWindow.parent); } return curWindow.document; } function FindParentDoc(curWindow) { if (curWindow == null) return null; if (curWindow.parent == null) return null; return curWindow.parent.document; } function FindTargetDoc(curWindow, target) { if (curWindow == null) return null; if (curWindow.frames[target]) { return curWindow.frames[target]; } else if ((curWindow.parent != null) && (curWindow.parent != curWindow)) { return this.FindTargetDoc(curWindow.parent, target); } return null; } function GoLink(url,target) { // gaurd if (url == null) return; if (url.length == 0) return; //. if (target == "_blank") { window.open(url); } else { var target_doc = null; if (target == null || target.length == 0 || target == "_self") { target_doc = document; } else if (target == "_top") { target_doc = FindTopDoc(window); } else if (target == "_parent") { target_doc = FindParentDoc(window); } else { target_doc = FindTargetDoc(window, target); } //. if (target_doc == null) { window.open(url); } else { target_doc.location.href = url; } } } function HitTest() { if (null == document.all) return true; return ( window.event.x > 0 && window.event.x < document.all[Me.target].offsetWidth && window.event.y > 0 && window.event.y < document.all[Me.target].offsetHeight); } function UpdateSrcText(var_name,update_text) { var i = 0; var parse_text = ""; for (i = 0; i < update_text.length; i ++) { if ('\'' == update_text.charAt(i)) parse_text = parse_text + "\\"; parse_text = parse_text + update_text.charAt(i); } eval(var_name + "='" + parse_text + "'; "); } function AddLink(src_text,text_link) { var text_res = ""; if (text_link.length) text_res = "<A href='" + text_link + "'>" + src_text + "</A>"; else text_res = src_text; return text_res; } function GetLayer(target) { var target_layer; if (document.all) { target_layer = document.all[target]; } else if (document.layers) { if (document.layers[target + "_layer"]) target_layer = document.layers[target + "_layer"]; else target_layer = document.layers[target].document.layers[target + "_layer"]; } return target_layer; } function UpdateLayer(target,restext) { var target_layer; target_layer = GetLayer(target); if (document.all) { target_layer.innerHTML = restext; } else if (document.layers) { target_layer.document.open("text/html"); target_layer.document.write(restext); target_layer.document.close(); } } function AddTextLink(strLink) { LinkList[LinkList.length] = strLink; } function GoTextLink(LinkIndex) { GoLink(LinkList[LinkIndex],''); } function ReloadPage() { for (i = 0 ; i < Timer.length ; i++) clearTimout(Timer[i]); document.location.reload(false); } function setJSTimeout(name,callback,delay) { setTimeout("if ('undefined' != typeof(" + name + ")) " + callback + " else document.location.reload(true);",delay); } function ReplaceImageNS(layername,name, state) { var CurDoc; if (document.layers) CurDoc = document.layers[layername].document.layers[layername + "_layer"].document; else CurDoc = document; if (bIsSupportOK) { for (i = 0; i < imgCounter; i++) { if (CurDoc.images[ImageList[i][NameIndex]] != null) { if ((name == ImageList[i][NameIndex]) && (ImageList[i][state] != null)) CurDoc.images[name].src = ImageList[i][state].src; } } } } //--> </SCRIPT> <SCRIPT> <!-- function TextBlock_Clone() { var newObject = new TextBlock(), i; newObject.UseFont = this.UseFont; newObject.UseSize = this.UseSize; newObject.UseBold = this.UseBold; newObject.UseItalic = this.UseItalic; newObject.UseUnderLine = this.UseUnderLine; newObject.UseTextColor = this.UseTextColor; newObject.UseBackColor = this.UseBackColor; newObject.BackColor = this.BackColor; newObject.TextColor = this.TextColor; newObject.Font = this.Font; newObject.Size = this.Size; return newObject; } function TextBlock() { this.Clone= TextBlock_Clone; this.UseFont = false; this.UseFontSize= false; this.UseBold = false; this.UseItalic = false; this.UseUnderLine = false; this.UseTextColor = false; this.UseBaclColor = false; this.RenderLink = false; } function MakeTextBlock(srctext,block) { var restext = ""; if (block.UseBackColor) restext = restext + "<span style='background-color:" + block.BackColor + "'>" if (block.UseTextColor) restext = restext + "<font color=" + '"' + block.TextColor + '"' + ">"; if (block.UseFont)restext = restext + "<font face='" + block.Font + "'>"; if (block.UseSize)restext = restext + "<font size='" + block.Size + "'>"; if (block.UseBold)restext = restext + "<STRONG>"; if (block.UseItalic) restext = restext + "<EM>"; if (block.UseUnderLine) restext = restext + "<U>"; restext = restext + srctext; if (block.UseUnderLine) restext = restext + "</U>"; if (block.UseItalic) restext = restext + "</EM>"; if (block.UseBold)restext = restext + "</STRONG>"; if (block.UseFont)restext = restext + "</font>"; if (block.UseSize)restext = restext + "</font>"; if (block.UseTextColor) restext = restext + "</font>"; if (block.UseBackColor) restext = restext + "</span>"; return restext; } //--> </SCRIPT> <SCRIPT> <!-- function BlinkTextBlock(srctext,block) { // Init var restext = ""; var cattext = ""; var curPos = -1; var prechar = 0; var IsInQuote= false; // Compose new text for (i = 0; i < srctext.length; i++) { if ('<' == srctext.charAt(i)) { if ("" != cattext) restext = restext + MakeTextBlock(cattext,block); cattext = ""; IsInQuote = true; } if (false == IsInQuote) curPos ++; if ('>' == srctext.charAt(i)) IsInQuote = false; if (IsInQuote || '>' == srctext.charAt(i)) { restext = restext + srctext.charAt(i); } else { cattext = cattext + srctext.charAt(i); // restext = restext + MakeTextBlock(srctext.charAt(i),block); } prechar = srctext.charAt(i); } if (cattext) restext = restext + MakeTextBlock(cattext,block); return restext; } //--> </SCRIPT> <SCRIPT> <!-- function RotatorEffect_GetLayer(layer_name) { if (document.all) return document.all[layer_name]; else if (document.layers) document.layers[layer_name]; else return null; } function RotatorEffect_SetTop(TopPos) { var Me = this; if (document.all) document.all[Me.target].style.posTop = TopPos; else if (document.layers) document.layers[Me.target].top = TopPos; } function RotatorEffect_GetTop() { var Me = this; if (document.all) return document.all[Me.target].style.posTop; else if (document.layers) return document.layers[Me.target].top; } function RotatorEffect_ScrollTimer(target,cy) { var Me = this; var i; var IsReset = false; if (this.num != 0) return; if (Me.counter.poser && 0 == (Me.counter.poser % Me.ClipHeight)) IsReset = true; if (Me.counter.Stop) { setTimeout("if ('undefined' == typeof(" + this.name + ")) document.location.reload(true); else " + Me.name + ".ScrollTimer('" + target + "'," + cy + ");",Me.DelayTime); return; } for (i = 0; i < this.counter.stack.length; i++) { var item = this.counter.stack[i]; item.ScrollText(item.target,cy); } if (0 == this.num) this.counter.poser ++; if (IsReset) setTimeout("if ('undefined' == typeof(" + this.name + ")) document.location.reload(true); else " + Me.name + ".ScrollTimer('" + target + "'," + cy + ");",Me.RepeatDelay); else setTimeout("if ('undefined' == typeof(" + this.name + ")) document.location.reload(true); else " + Me.name + ".ScrollTimer('" + target + "'," + cy + ");",Me.DelayTime); } function RotatorEffect_ScrollText(target,cy) { var Me = this; var IsReset = false; var IsSizing= false; var text_attr = Me.text_attr.Clone(); var new_text; if (document.all) CellHeight = document.all[target].offsetHeight; else if (document.layers) CellHeight = Me.ClipHeight; if (Me.GetTop() <= (Me.OrgTop - 2 * Me.ClipHeight)) { factor = (Me.counter.count > 1)? Me.counter.count - 2 : 0 ; Me.YClip = 0; Me.ClipTop = 0; Me.ClipBottom = 0; Me.YOff= 0; Me.SetTop(Me.OrgTop + factor * Me.ClipHeight); } else { if (Me.GetTop() <= (Me.OrgTop - Me.ClipHeight + 1)) Me.ClipTop = Me.ClipTop + cy; if (Me.GetTop() < (Me.OrgTop)) Me.ClipBottom= Me.ClipBottom + cy; } if (Me.GetTop() < (Me.OrgTop) && Me.GetTop() >= (Me.OrgTop - Me.ClipHeight + 1)) IsSizing = true; NewClip = 'rect(' + Me.ClipTop + ' ' + Me.ClipRight + ' ' + Me.ClipBottom + ' ' + Me.ClipLeft + ')'; // Test if (IsSizing) { switch(Me.GetTop() % 9) { case 6: case 7: case 8: text_attr.Size = text_attr.Size + 1; break; case 0: case 1: case 2: text_attr.Size = text_attr.Size - 1; break; } } // Update New Text HTML if (Me.text) new_text = AddLink(BlinkTextBlock(Me.text,text_attr),Me.text_link); // Update Layer if (document.all) { if (1 == Me.First) { Me.First = 0; // document.all[target].style.posTop =document.all[target].offsetTop + Me.ClipHeight + Me.YOff; document.all[target].style.posTop =document.all[this.counter.target].offsetTop + Me.ClipHeight + Me.YOff; document.all[target].style.posLeft=document.all[this.counter.target].offsetLeft; Me.OrgTop = document.all[target].style.posTop - Me.YOff; } document.all[target].style.posTop = document.all[target].style.posTop - cy; document.all[target].style.clip = NewClip; if (Me.text) document.all[target].innerHTML = new_text; } else if (document.layers) { if (1 == Me.First) { Me.First = 0; Me.OrgTop = document.layers[target].top - Me.YOff; } document.layers[target].top = document.layers[target].top - cy; document.layers[target].clip.top = Me.ClipTop; document.layers[target].clip.bottom = Me.ClipBottom; if (Me.text) { document.layers[target].document.open() document.layers[target].document.write(new_text); document.layers[target].document.close(); } } } function RotatorEffect_Init(target,target_NS,delay,YOff,ClipWidth,ClipHeight,text,text_link,text_color,text_face,text_size,RepeatTime) { var Me = this; if (document.layers) { if (document.layers[target] == null) Me.target = target_NS; else Me.target = target; //target_NS ???; document.layers[Me.target].top = document.layers[this.counter.target].top + ClipHeight + YOff; document.layers[Me.target].left= document.layers[this.counter.target].left; } else if (document.all) { Me.target= target; // document.all[target].style.posTop =document.all[this.counter.target].offsetTop + ClipHeight + YOff; // document.all[target].style.posLeft=document.all[this.counter.target].offsetLeft; } Me.First= 1; Me.YOff = YOff; Me.YClip= 1; Me.ClipWidth = ClipWidth; Me.ClipHeight = ClipHeight; Me.ClipLeft= 0; Me.ClipRight = ClipWidth; Me.ClipTop= 0; Me.ClipBottom = 0; Me.DelayTime = delay; Me.RepeatDelay = RepeatTime; Me.Repeat = true; Me.text = text; Me.text_link = text_link; Me.text_attr = new TextBlock(); Me.text_attr.UseTextColor = true; Me.text_attr.UseFont = true; Me.text_attr.UseSize = true; Me.text_attr.TextColor = text_color; Me.text_attr.Font = text_face; Me.text_attr.Size = text_size; setTimeout(Me.name + ".ScrollTimer('" + Me.target + "',1);",50); } function RotatorEffect_OnMouseOver(event) { if (this.PauseOnOver) this.counter.Stop = true; var target_layer = GetLayer(this.counter.target); if (target_layer) if (target_layer.onmouseover) target_layer.onmouseover(event); } function RotatorEffect_OnMouseOut(event) { if (this.PauseOnOver) this.counter.Stop = false; var target_layer = GetLayer(this.counter.target); if (target_layer) if (target_layer.onmouseout) target_layer.onmouseout(event); } function RotatorStack(target) { this.count= 0; this.Stop= false; this.target= target; this.stack= new Array; this.poser= 0; } function RotatorEffect(name,counter,IsPause) { this.Init = RotatorEffect_Init; this.ScrollTimer = RotatorEffect_ScrollTimer; this.ScrollText = RotatorEffect_ScrollText; this.SetTop = RotatorEffect_SetTop; this.GetTop = RotatorEffect_GetTop; this.GetLayer = RotatorEffect_GetLayer; this.OnMouseOver = RotatorEffect_OnMouseOver; this.OnMouseOut = RotatorEffect_OnMouseOut; this.name= name; this.counter= counter; this.num = this.counter.count; this.PauseOnOver = IsPause; this.counter.count ++; this.counter.stack[this.counter.stack.length] = this; } //--> </SCRIPT> </HEAD> <BODY TOPMARGIN="0" LEFTMARGIN="0" MARGINWIDTH="0" MARGINHEIGHT="0"> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0"> <TR> <TD COLSPAN="3"><IMG SRC="upi7876_1.jpg" WIDTH="960" BORDER="0" HEIGHT="2"></TD> </TR> <TR> <TD><IMG SRC="upi7876_2.jpg" WIDTH="2" BORDER="0" HEIGHT="59"></TD> <TD WIDTH="438" HEIGHT="59"><SPAN ID="xxID2" TOP="2" LEFT="2" STYLE="left: 2; top: 2; width: 438; height: 59; position: absolute;"><LAYER ID="xxID2_layer"><A HREF="http://www.1und1.de/"><IMG SRC="upi7876_3.jpg" WIDTH="438" BORDER="0" HEIGHT="59"></A></LAYER></SPAN><IMG SRC="space.gif" WIDTH="438" HEIGHT="59"></TD> <TD><IMG SRC="upi7876_4.jpg" WIDTH="520" BORDER="0" HEIGHT="59"></TD> </TR> <TR> <TD COLSPAN="3"><IMG SRC="upi7876_5.jpg" WIDTH="960" BORDER="0" HEIGHT="4"></TD> </TR> </TABLE> <SPAN ID="xxID2_0" STYLE="position: absolute;" ONMOUSEOUT="if (rotator_xxID2_0) rotator_xxID2_0.OnMouseOut();" ONMOUSEOVER="if (rotator_xxID2_0) rotator_xxID2_0.OnMouseOver();"> <LAYER ID="xxID2_0_layer" ONMOUSEOUT="if (rotator_xxID2_0) rotator_xxID2_0.OnMouseOut();" ONMOUSEOVER="if (rotator_xxID2_0) rotator_xxID2_0.OnMouseOver();"> <A href='http://www.anatolij-ustjuschin.de'><font color='#000000' face='' size=1296816><IMG SRC="Banner.468x60.gif.1.gif" width=438 height=59 border=0 alt=''></font></A></LAYER> </SPAN> <SPAN ID="xxID2_1" STYLE="position: absolute;" ONMOUSEOUT="if (rotator_xxID2_1) rotator_xxID2_1.OnMouseOut();" ONMOUSEOVER="if (rotator_xxID2_1) rotator_xxID2_1.OnMouseOver();"> <LAYER ID="xxID2_1_layer" ONMOUSEOUT="if (rotator_xxID2_1) rotator_xxID2_1.OnMouseOut();" ONMOUSEOVER="if (rotator_xxID2_1) rotator_xxID2_1.OnMouseOver();"> <A href='http://www.photoimpact.forum24.ru'><font color='#000000' face='' size=1296816><IMG SRC="Banner.Nostalgia.468x60.gif" width=438 height=59 border=0 alt=''></font></A></LAYER> </SPAN> <SPAN ID="xxID2_2" STYLE="position: absolute;" ONMOUSEOUT="if (rotator_xxID2_2) rotator_xxID2_2.OnMouseOut();" ONMOUSEOVER="if (rotator_xxID2_2) rotator_xxID2_2.OnMouseOver();"> <LAYER ID="xxID2_2_layer" ONMOUSEOUT="if (rotator_xxID2_2) rotator_xxID2_2.OnMouseOut();" ONMOUSEOVER="if (rotator_xxID2_2) rotator_xxID2_2.OnMouseOver();"> <A href='http://www.photoimpact.0pk.ru'><font color='#000000' face='' size=1296816><IMG SRC="BannerP.I.-22.gif" width=438 height=59 border=0 alt=''></font></A></LAYER> </SPAN> </BODY> <SCRIPT> <!-- if (document.layers) window.onresize = new Function("ReloadPage();"); if (document.layers) { if (document.layers['xxID2_layer']) document.layers['xxID2_layer'].top = 2; if (document.layers['xxID2_layer']) document.layers['xxID2_layer'].left = 2; }; if (document.all) { if (document.all['xxID2']) document.all['xxID2'].style.position='absolute' }; counter_xxID2 = new RotatorStack('xxID2');rotator_xxID2_0 = new RotatorEffect('rotator_xxID2_0',counter_xxID2,true); rotator_xxID2_0.Init('xxID2_0','xxID2_0_layer',50,0,438,59,'','','#980092','',1262012,1000); rotator_xxID2_1 = new RotatorEffect('rotator_xxID2_1',counter_xxID2,true); rotator_xxID2_1.Init('xxID2_1','xxID2_1_layer',50,59,438,59,'','','#980092','',1262012,1000); rotator_xxID2_2 = new RotatorEffect('rotator_xxID2_2',counter_xxID2,true); rotator_xxID2_2.Init('xxID2_2','xxID2_2_layer',50,118,438,59,'','','#980092','',1262012,1000); //--> </SCRIPT>
Теперь вопрос. Как это заставить работать в шапке форума как задумано? Ведь не могу же я загнать в стили вместо адреса картинки таблицу со скриптами.
Для установки рекламного баннера тоже использовалась таблица. Быть может есть смысл добавить в неё ещё одну ячейку с размерами стандартного баннера 468х60 и отдать это окно в распоряжение админам?
Что посоветуете? Хотелось бы чтобы место не пустовало а приносило пользу. Да и симметрия придаёт совсем другой вид форуму.
Отредактировано Anatolij.U (2009-02-06 13:20:04)