Click here to Skip to main content
15,911,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I am currently updating the http://www.yapi.com.tr/AnaSayfa/. When I mouseover the 1,2,3,4,5 images, the news does not change. That is what I want when I mouseover the image as well. What should I do ? Using google chrome you can see the code.

Modification: /JScript/Manset.js

JavaScript
// body onload
function Start() {
Haberler_Show(1);
Haberler_timerStart(1);
Etkinlikler_Show(1);
Etkinlikler_timerStart(1);
UrunHaberleri_Show(1);
UrunHaberleri_timerStart(1);
Sektorden_Show(1);
Sektorden_timerStart(1);
Yarismalar_Show(1);
Yarismalar_timerStart(1);
Oduller_Show(1);
Oduller_timerStart(1);
}
/* Haberler Başlangıç */
var Haberler_counter = 1;
var Haberler_timerCount;
var Haberler_maxHeaderlineCount = 5;
function Haberler_Show(Haberler_selectedItemIndex) {
//HERE I STOP THE TIMER
Haberler_stopTimer();
for (i = 1; i <= Haberler_maxHeaderlineCount; i++) {
if (i != Haberler_selectedItemIndex) {
document.getElementById('Haberler_Resim_' + i).style.display = 'none';
document.getElementById('Haberler_Sayi_Resim_' + i).src = '../Images/PageNumber/' + i + '.jpg';
document.getElementById('Haberler_Detay_' + i).style.display = 'none';
}
else {
document.getElementById('Haberler_Resim_' + i).style.display = 'block';
document.getElementById('Haberler_Sayi_Resim_' + i).src = '../Images/PageNumber/' + i + '_hover.jpg';
document.getElementById('Haberler_Detay_' + i).style.display = 'block';
}
}
}
function Haberler_timerStart(Haberler_counterNum) {
if (Haberler_counterNum != -1)
Haberler_counter = Haberler_counterNum;
if (Haberler_counter == Haberler_maxHeaderlineCount + 1) Haberler_counter = 1;
for (i = 1; i <= Haberler_maxHeaderlineCount; i++) {
if (i != Haberler_counter) {
document.getElementById('Haberler_Resim_' + i).style.display = 'none';
document.getElementById('Haberler_Sayi_Resim_' + i).src = '../Images/PageNumber/' + i + '.jpg';
document.getElementById('Haberler_Detay_' + i).style.display = 'none';
}
else {
document.getElementById('Haberler_Resim_' + i).style.display = 'block';
document.getElementById('Haberler_Sayi_Resim_' + i).src = '../Images/PageNumber/' + i + '_hover.jpg';
document.getElementById('Haberler_Detay_' + i).style.display = 'block';
}
}
Haberler_counter = Haberler_counter + 1;
Haberler_timerCount = setTimeout("Haberler_timerStart(-1)", 5000);
}
function Haberler_stopTimer() {
clearTimeout(Haberler_timerCount);
}


Thanks in advance,

Nice
Posted
Updated 8-Dec-10 3:24am
v2
Comments
Manfred Rudolf Bihy 8-Dec-10 8:38am    
You have to be more precise, when you mouse over 1,2,3,4,5 the timer driven news change is suspended. I tried your page and thought WTF, but now I got it :)
Oh no: in IE news change is suspended on mouseover of images 1,2,3,4,5, but it's not working in FireFox. Is this intended to work correctly primarily in Internet Exploder?
Close Network 8-Dec-10 8:48am    
sorry on http://www.yapi.com.tr/AnaSayfa/ when I mouseover 1,2,3,4,5 images, the news (Haberler) do change. It does not work here either.
Close Network 8-Dec-10 8:49am    
yes you are right, in IE it does not change, in chrome it changes.
Manfred Rudolf Bihy 8-Dec-10 8:52am    
And also in FireFox!
Close Network 8-Dec-10 8:53am    
it must work in all browsers. when I mouseover images, the timer driven news should be suspended.

You could use clearTimeout for that.
http://www.w3schools.com/js/js_timing.asp[^]

Another method would simply be to check some variable that you defined that represents some value that indicates if there should be any action or not.

You can use the mouseenter/mouseleave for it.

Good luck!
 
Share this answer
 
Comments
Close Network 8-Dec-10 8:41am    
I am already using clearTimeOut. http://www.yapi.com.tr/JScript/Manset.js
E.F. Nijboer 8-Dec-10 8:45am    
Did you look at the example on w3c school?
// Global variable to hold timer reference
var t;
...
// set timer and store reference in t
t=setTimeout("timedCount()",1000);
...
// stop timer with referenced in t
clearTimeout(t);
Close Network 8-Dec-10 9:08am    
The problem is that onmouseover 1,2,3,4,5 images (using Firefox and Google Chrome), clearTimeOut does not function. in IE it works when I mouseover 1,2,3,4,5 images.
E.F. Nijboer 8-Dec-10 9:34am    
I think the problem is that there are multiple timers set. So instead of just do a setTimer:
t=setTimeout('...',1000);
It would be better to do a clearTimeout, just in case t was already set with a timer reference.
clearTimeout(t);t=setTimeout('someAction();',1000);
Manfred Rudolf Bihy 8-Dec-10 9:37am    
Hi Close, did something change? FireFox seems to be working all of a sudden whilst Chrome is still not playing nicely.
Here is the relevant js file.
http://www.yapi.com.tr/JScript/Manset.js

Here is the only code that is relevant.

I commented where I use Haberler_Show and I also stopped the timer when entering this method.

I have been trying to find a solution for hours. I have already looked.

Thanks in advance,
Nice

// body onload
function Start() {
Haberler_Show(1);
Haberler_timerStart(1);
Etkinlikler_Show(1);
Etkinlikler_timerStart(1);
UrunHaberleri_Show(1);
UrunHaberleri_timerStart(1);
Sektorden_Show(1);
Sektorden_timerStart(1);
Yarismalar_Show(1);
Yarismalar_timerStart(1);
Oduller_Show(1);
Oduller_timerStart(1);
}

/* Haberler Başlangıç */
var Haberler_counter = 1;
var Haberler_timerCount;
var Haberler_maxHeaderlineCount = 5;
function Haberler_Show(Haberler_selectedItemIndex) {
//HERE I STOP THE TIMER
Haberler_stopTimer();
for (i = 1; i <= Haberler_maxHeaderlineCount; i++) {
if (i != Haberler_selectedItemIndex) {
document.getElementById('Haberler_Resim_' + i).style.display = 'none';
document.getElementById('Haberler_Sayi_Resim_' + i).src = '../Images/PageNumber/' + i + '.jpg';
document.getElementById('Haberler_Detay_' + i).style.display = 'none';
}
else {
document.getElementById('Haberler_Resim_' + i).style.display = 'block';
document.getElementById('Haberler_Sayi_Resim_' + i).src = '../Images/PageNumber/' + i + '_hover.jpg';
document.getElementById('Haberler_Detay_' + i).style.display = 'block';
}
}
}
function Haberler_timerStart(Haberler_counterNum) {
if (Haberler_counterNum != -1)
Haberler_counter = Haberler_counterNum;
if (Haberler_counter == Haberler_maxHeaderlineCount + 1) Haberler_counter = 1;
for (i = 1; i <= Haberler_maxHeaderlineCount; i++) {
if (i != Haberler_counter) {
document.getElementById('Haberler_Resim_' + i).style.display = 'none';
document.getElementById('Haberler_Sayi_Resim_' + i).src = '../Images/PageNumber/' + i + '.jpg';
document.getElementById('Haberler_Detay_' + i).style.display = 'none';
}
else {
document.getElementById('Haberler_Resim_' + i).style.display = 'block';
document.getElementById('Haberler_Sayi_Resim_' + i).src = '../Images/PageNumber/' + i + '_hover.jpg';
document.getElementById('Haberler_Detay_' + i).style.display = 'block';
}
}
Haberler_counter = Haberler_counter + 1;
Haberler_timerCount = setTimeout("Haberler_timerStart(-1)", 5000);
}
function Haberler_stopTimer() {
clearTimeout(Haberler_timerCount);
}
 
Share this answer
 
Comments
Manfred Rudolf Bihy 8-Dec-10 9:20am    
Please don't post stuff as an answer. Leave things like that either as an comment to or as a modification to your question. Thank you!
Manfred Rudolf Bihy 8-Dec-10 9:33am    
Moved to OPs question.
Hi Close,
I found it using Fiddler2. The function that is being called in function Haberler_Show(item) is called Haberler_stopTimer(). So on the divs with the id="Haberler_Resim_X" where X runs from 1 to 5 you'd have to do onmouseover="Haberler_stopTimer();" and onmouseout="Haberler_timerStart(-1)".
That should do it, for the first news box. Second one should be analogous.

Cheers,

Manfred
 
Share this answer
 
Comments
Close Network 8-Dec-10 9:42am    
I could not comment, instead I added an answer, please check.
Manfred Rudolf Bihy 8-Dec-10 9:54am    
By leaving a comment you proved that you could.
XML
it says : Microsoft JScript error: Object Expected
Haberler_StopTimer() expects a parameter, an object. I broke the debugging here at this point.
Beside in IE it still does not work. Sorry.

<div id="Haberler_Resim_1" class="MansetResimAktif" style="display: block;" onmouseover="Haberler_StopTimer();" önmouseout="Haberler_timerStart(-1);"><a href="../Haberler/atasehire-selimiye_84258.html" title="Ataşehir’e Selimiye..."><img src="http://www.yapi.com.tr/V_Images/2010/haberler/mtn_84258_Selimiye-camii.jpg" alt="Ataşehir’e Selimiye..." class="MansetHaberlerResim" border="0" /></a></div>


onmouseover="Haberler_StopTimer();" onmouseout="Haberler_timerStart(-1)
 
Share this answer
 
v2
Comments
Manfred Rudolf Bihy 8-Dec-10 10:01am    
I already told you, this is not an answer! Question edits or comments were made for that. Please adhere to the forum guidelines. Thank you!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900