форум vBSupport.ru > vBulletin > Вопрос — Ответ
  • »
VBsupport перешел с домена .ORG на родной .RU Ура! Пожалуйста, обновите свои закладки - VBsupport.ru
 
 
 
 
Exinaus
Продвинутый
Default Событие OnLoad
0

Суть проблемы вот в чем:
В шапке header форума находится отличный от стандартного логотип, в нем пункты меню навигации выполнены в виде рисунка который с помощью Ява скрипта меняет рисунки при наведении мышки на рисунок. На большинстве страниц он работает замечательно, но на страницах где встречается код:
Code:
<body onload="$onload">
Ява скрипт отказывается выполнятся. Там где в шаблонах простой <body> скрипт выполняется на ура.

Текст ява скрипта:
Code:
<script type="text/javascript">
<!--

// педварительная загрузка картинки_2

  img1=new Image(); img1.src="about_on.jpg";
  img2=new Image(); img2.src="forum_on.jpg";
  //....

function init() {
  if (!document.getElementById) return
  var imgOriginSrc;
  var imgTemp = new Array();
  var imgarr = document.getElementsByTagName('img');
  for (var i = 0; i < imgarr.length; i++) {
    if (imgarr[i].getAttribute('hsrc')) {
        imgTemp[i] = new Image();
        imgTemp[i].src = imgarr[i].getAttribute('hsrc');
        imgarr[i].onmouseover = function() {
            imgOriginSrc = this.getAttribute('src');
            this.setAttribute('src',this.getAttribute('hsrc'))
        }
        imgarr[i].onmouseout = function() {
            this.setAttribute('src',imgOriginSrc)
        }
    }
  }
}
onload=init;
-->
</script>
Ну и код для рисунка:

Code:
<img alt="" border="0" src="about_off.jpg" hsrc="about_on.jpg">
Как подружить данный скрипт с кодом форума?

Добавлено через 11 часов 13 минут
В общем поблагодарил бы за помощь, да помощи нету ....

Пришлось в исходниках лазить ... хоть и не люблю я этого ...

Может кому и пригодится:

в class_postbit.php надо найти код:

Code:
		// check for autoscrolling
		global $postid, $onload, $threadedmode;
		if ($this->post['postid'] == $postid)
		{
			$this->post['scrolltothis'] = ' id="currentPost"';
			if ($threadedmode == 0)
			{
				$onload = "if (is_ie || is_moz) { fetch_object('currentPost').scrollIntoView(true); };";
			}
		}
		else
		{
			$this->post['scrolltothis'] = '';
		}
И заменить на:

Code:
		// check for autoscrolling
		global $postid, $onload, $threadedmode;
		if ($this->post['postid'] == $postid)
		{
			$this->post['scrolltothis'] = ' id="currentPost"';
			if ($threadedmode == 0)
			{
				$onload = "if (is_ie || is_moz) { fetch_object('currentPost').scrollIntoView(true); }; init();";
			}
		}
		else
		{
			$this->post['scrolltothis'] = '';
			$onload = "init();";
		}
В моем случае функция называлсь init();, в вашем может по другому ...

Last edited by Exinaus : 11-20-2007 at 03:26 AM. Reason: Добавлено сообщение
Bot
Yandex Bot Yandex Bot is online now
 
Join Date: 05.05.2005
Реклама на форуме А что у нас тут интересного? =)
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT +4. The time now is 09:28 PM.


Powered by vBulletin® Version 3.0.14
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Loading...