473,779 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Delay counter

Hi. Is there a way to delay a call to a page counter (ie. call to a
server script from an IMG tag) for the purpose to not lock the page
loading awaiting counter be displayed.

Maybe a setTimeout() launching an equivalent of "document.write ", but
writing in a specific DIV ? Thanks in advance for your ideas.

Actually, the counter is called (without delay) like this :

<div id="count" style="position : absolute; visibility: visible; top:
20px; left: 20px; width: auto; height: auto; z-index: 5; cursor:
default"><img src="http://host.com/cgi-bin/counter.exe?col or=red&font=
6"></div>
Nov 6 '05 #1
7 3448
VK

JellyON wrote:
Hi. Is there a way to delay a call to a page counter (ie. call to a
server script from an IMG tag) for the purpose to not lock the page
loading awaiting counter be displayed.

Maybe a setTimeout() launching an equivalent of "document.write ", but
writing in a specific DIV ? Thanks in advance for your ideas.

Actually, the counter is called (without delay) like this :

<div id="count" style="position : absolute; visibility: visible; top:
20px; left: 20px; width: auto; height: auto; z-index: 5; cursor:
default"><img src="http://host.com/cgi-bin/counter.exe?col or=red&font=
6"></div>


Rendering delay happens not because of a server call by itself - but
because the engine cannot allocate the image until the image header
(with width and height) is received. As a result it cannot allocate
(render) the whole <div>.

If say it's a 128x32 image then this would solve the problem:
<div id="count" style="position : absolute; visibility: visible; top:
20px; left: 20px; width: auto; height: auto; z-index: 5; cursor:
default"><img src="http://host.com/cgi-bin/counter.exe?col or=red&font=
6" width="128" height="32"></div>

If you server script is *very* slow (so user will see a red crossed
"missing image" sign for a while), you can fix the situation by:

<div id="count" style="position : absolute; visibility: visible; top:
20px; left: 20px; width: auto; height: auto; z-index: 5; cursor:
default"><img src="TempTransp arent.gif" width="128" height="32"
onload="
if (this.src='Temp Transparent.gif ') {
this.src='http://host.com/cgi-bin/counter.exe?col or=red&font= 6';
}"></div>

Nov 6 '05 #2
VK
! Nasty typo !
Read:
if (this.src=='Tem pTransparent.gi f') {
this.src='http://host.com/cgi-bin/counter.exe?col or=red&font= 6';
}">

Nov 6 '05 #3
In article <11************ **********@g14g 2000cwa.googleg roups.com>,
sc**********@ya hoo.com says...
! Nasty typo !
Read:
if (this.src=='Tem pTransparent.gi f') {
this.src='http://host.com/cgi-bin/counter.exe?col or=red&font= 6';
}">


Thanks a lot VK. I will try your piece of code asap.
Nov 6 '05 #4
In article <11************ **********@g14g 2000cwa.googleg roups.com>,
sc**********@ya hoo.com says...
! Nasty typo !
Read:
if (this.src=='Tem pTransparent.gi f') {
this.src='http://host.com/cgi-bin/counter.exe?col or=red&font= 6';
}">


Well, it sounds right :-) I've just replaced the if by a

setTimeout(func tion(){this.src ='http://host.com/cgi-bin/counter.exe?
color=red&font= 6';});

because it's better for delaying counter call and I didn't seen the
reason why for testing "TempTransparen t.gif" presence (obviously always
here). Maybe something I've missed ?

Well, now, it stay just a thing : I would like to display another DIV
(which contain a text like "Number of hits : ") only if counter call
succeeded. The question is not to know how to show the DIV (simply
change the visibility style attribute), but what to test. That is the
question !
Nov 6 '05 #5
VK

JellyON wrote:
Well, it sounds right :-) I've just replaced the if by a

setTimeout(func tion(){this.src ='http://host.com/cgi-bin/counter.exe?
color=red&font= 6';});

because it's better for delaying counter call and I didn't seen the
reason why for testing "TempTransparen t.gif" presence (obviously always
here). Maybe something I've missed ?
I did not mean to test for "TempTransparen t.gif". The idea was to have
TempTransparent .gif loaded right away so user does not see empty image
frame. And right upon the TempTransparent .gif load you request the
counter picture so it appears on the page when ready. setTimeout is an
option but why make things more difficult as they should be? ;-)
Well, now, it stay just a thing : I would like to display another DIV
(which contain a text like "Number of hits : ") only if counter call
succeeded. The question is not to know how to show the DIV (simply
change the visibility style attribute), but what to test. That is the
question !


Error event supported by images since Netscape 3 - what else?

The combined code could be:
....
<img name="myCounter " src="myTranspar ent.gif" width="128" height="32"

onload="
if (this.src == 'myTransparent. gif') {
this.src='http://host.com/cgi-bin/counter.exe?col or=red&font=6';
this.failedToLo ad=false;
}
else {
document.getEle mentById('myDiv ').style.visibi lity = 'visible';
}"

onerror="
this.src='myOop s.gif';
this.failedToLo ad=true;"
/>
....

As you cannot predict when exactly the counter will arrive, you better
let counter itself to make your <DIV> to appear, not vice versa.

To check the situation *later* (is counter loaded? is div displayed?)
you can always check the custom property failedToLoad:
if (document.image s['myCounter'].failedToLoad) {
// I got some problems
}

Unlikely in your case, but be careful with animated gif's: they produce
new "load" event on each animation cicle (a very old GIF98a bug which
will never be fixed now).

Also make sure that at least 'myOops.gif' is always available,
otherwise you'll put your script into onerror loop. It also can be
fixed programmaticall y, but easier and better simply to have this image
on your server.

Nov 6 '05 #6
In article <11************ *********@z14g2 000cwz.googlegr oups.com>,
sc**********@ya hoo.com says...
onload="
if (this.src == 'myTransparent. gif') {
this.src='http://host.com/cgi-bin/counter.exe?col or=red&font=6';
this.failedToLo ad=false;
}


OK, it works unless the "if (this.src == 'myTransparent. gif')" because
the myTransparent.g if image has not always time to load before the
onload event. Not sure about this diagnostic, but has to be tried less
tired (me). Good night !
Nov 6 '05 #7
JellyON said the following on 11/6/2005 5:34 AM:
Hi. Is there a way to delay a call to a page counter (ie. call to a
server script from an IMG tag) for the purpose to not lock the page
loading awaiting counter be displayed.
Display a transparent image temporarily. Use the window.onload (or body
onload) to trigger a function that will change the images src attribute
accordingly.
Maybe a setTimeout() launching an equivalent of "document.write ", but
writing in a specific DIV ? Thanks in advance for your ideas.

Actually, the counter is called (without delay) like this :

<div id="count" style="position : absolute; visibility: visible; top:
20px; left: 20px; width: auto; height: auto; z-index: 5; cursor:
default"><img src="http://host.com/cgi-bin/counter.exe?col or=red&font=
6"></div>

<img src="http://yourDomain.com/transparent.gif " name="counterIm age"
width="##" height="##">

along with this script:

function changeCounterIm age(){
document.images['counterImage'].src="http://host.com/cgi-bin/counter.exe?col or=red&font=6";
}

window.onload = changeCounterIm age;

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 6 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
3807
by: Wolfgang Kaml | last post by:
Hello All, I have been researching newsgroups and knowledgebase all morning and not found a solution that would solve the problem I have. I am having an ASP or ASPX web page that implement a counter functionality and read/insert some data in a MS Access database on that Windows 2003 server. The weird part is, as long as the web page is very short in size, I can hit the refresh button and Internet Explorer will reload the page and display...
11
3765
by: Wolfgang Kaml | last post by:
Hello All, I have been working on this for almost a week now and I haven't anything up my sleeves anymore that I could test in addition or change.... Since I am not sure, if this is a Windows 2003 Server or ADO or ODBC issue, I am posting this on all of the three newsgroups. That's the setup: Windows 2003 Server with IIS and ASP.NET actiavted Access 2002 mdb file (and yes, proper rights are set on TMP paths and path,
14
18837
by: Des L. Davis | last post by:
System: Dell PowerEdge Server with 3 GB RAM, 2.4 GHz Celeron Software: Microsoft SQL Server 2000 Enterprise running on Windows 2003 Server Software: Microsoft SQL Server 2000 Enterprise running on Windows 2000 Server If you run the code below, you'll notice something odd occuring. The MilliSecond value does not change after a 1Millisecond delay. Is this a bug or am I doing something wrong? Any assistance will be greatly appreciated
2
16399
by: amos_s12 | last post by:
Hello everybody Is there a possibility to make a delay between two sql statements, namely one sql statement is performed, then there is a delay of some seconds and then rhe next statement is performed. In sybase database, there is a possibility to do such thing by using the statement waitfor delay 'hh:mm:dd' for example: while(...)
6
5564
by: lucifer | last post by:
hi i need to insert delay in my program what function should i use the old delay is not supported by the VC6
7
2943
by: mfeingold | last post by:
I am working on a system, which among other things includes a server and a ..net control sitting in an html page and connected to the server. I ran into a couple of problems, you guys might have some insight about. 1) It takes 20 sec or so to open a tcp socket from the client to the server. It just sits in the TcpClient.conect waiting for something. When I run the same control from a windows application it connects right away and works...
9
2356
by: krbyxtrm | last post by:
hello i have this profile for iterating empty vectors: +0.3us (microsecond) delay on intel pentium 2.4Ghz can this added delay to my application be reduced? i mean near zero delay, its very important. BTW, does anyone has another profile for this? thanks.
17
1790
by: Amy | last post by:
Hi, I finished this script and for some reason there is a delay every so often in the timing. Sometimes it seems two take 2 seconds instead of 1. Can anyone see anything that would slow it down? I sure can't see it. Thank you very much, Amy <body onload="changelink()"><a href="#" id="url"></a> arr = new Array(); arr = ; arr = ;
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10306
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9930
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2869
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.