Reloading Page without screen flickering, cursor changing

Hey

For my endwork, i need to reload a page which checks each second the mysql database for new records.
the problem is that the mouse cursor is always changing to wait mode and the screen is flickering.
Why checking every second? Because its very important for the stuff i need todo.
It must be kind of some 'status' which should change if the numbers of rows are increasing..

Is there any possible way to reload a page with JavaScript without flickering the screen neither a changing mouse cursor?
It must work in internet explorer, netscape and other browsers.. You have a solution?... Thanks in advance!!
xboneAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

bolesjCommented:

I have used this trick in the past and it seems to work well. Use a hidden Iframe embeded in your page and set the visablitiy = hidden. You can reload the iframe as many times as needed and the user will never see it. then use javascript to communicate changes from the Iframe into the parent window. It can get quite complicated depending on how much info you are trying to display but this has worked for me in the past.


0
xboneAuthor Commented:
can you please show some example code of it? it seems to work in internet explorer.. but in netscape/mozilla/konqueror the mouse cursor is still loading while reloading the iframe;.. what could i do please? help ;-) thanks in advance
0
xboneAuthor Commented:
can you please show some example code of it? it seems to work in internet explorer.. but in netscape/mozilla/konqueror the mouse cursor is still loading while reloading the iframe;.. what could i do please? help ;-) thanks in advance
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

xboneAuthor Commented:
i got a php page with the iframe in it:
check.php:

<?

echo "
        <html>
        <head>
        <script>
        function Hide()
        {
                iframe.style.visibility=\"hidden\";
        }
        </script>
        </head>
        <body>
        <iframe id=\"iframe\" name=\"iframe\" src=check2.php width=0 height=0 border=0>
        </iframe>
        </body>
        </html>
";

?>


and i got check2.php which includes the stuff which needs to be reloaded every second. but the problem is that the mouse cursor is always waiting/busy mode.. In netscape refresh == reload..

check2.php:
<?
session_start();
include('config.php');

echo "
        <html>
        <head>
        <script>
        function Reload()
        {
                window.location.reload(true);
        }
        function DoReloadPage()
        {
                clearTimeout();
                setTimeout('Reload()',1000);
        }
        </script>
        </head>
        <body onLoad=\"DoReloadPage()\">
";
if(! isset($counter))
{
        $counter=mysql_num_rows(mysql_query("select * from ip"));
        session_register("counter");
}
if($counter == mysql_num_rows(mysql_query("select * from ip")))
{
        echo "$counter";
}
else
{
        if($counter < mysql_num_rows(mysql_query("select * from ip")))
        {
                echo "<script>
                alert('New Record... Reload!');
                </script>";
                $counter=mysql_num_rows(mysql_query("select * from ip"));
                session_register("counter");
        }
}

echo "
</body>
</html>
";

?>


so can you help me find out why the mouse is still loading in netscape? Thanks ;-)

0
xboneAuthor Commented:
i got a php page with the iframe in it:
check.php:

<?

echo "
        <html>
        <head>
        <script>
        function Hide()
        {
                iframe.style.visibility=\"hidden\";
        }
        </script>
        </head>
        <body>
        <iframe id=\"iframe\" name=\"iframe\" src=check2.php width=0 height=0 border=0>
        </iframe>
        </body>
        </html>
";

?>


and i got check2.php which includes the stuff which needs to be reloaded every second. but the problem is that the mouse cursor is always waiting/busy mode.. In netscape refresh == reload..

check2.php:
<?
session_start();
include('config.php');

echo "
        <html>
        <head>
        <script>
        function Reload()
        {
                window.location.reload(true);
        }
        function DoReloadPage()
        {
                clearTimeout();
                setTimeout('Reload()',1000);
        }
        </script>
        </head>
        <body onLoad=\"DoReloadPage()\">
";
if(! isset($counter))
{
        $counter=mysql_num_rows(mysql_query("select * from ip"));
        session_register("counter");
}
if($counter == mysql_num_rows(mysql_query("select * from ip")))
{
        echo "$counter";
}
else
{
        if($counter < mysql_num_rows(mysql_query("select * from ip")))
        {
                echo "<script>
                alert('New Record... Reload!');
                </script>";
                $counter=mysql_num_rows(mysql_query("select * from ip"));
                session_register("counter");
        }
}

echo "
</body>
</html>
";

?>


so can you help me find out why the mouse is still loading in netscape? Thanks ;-)

0
bolesjCommented:

Hmmm..... Not quite sure what to tell you. you can do it the dirty way. I dont reccomend this but:

Spawn a new browser window off the screen. Have it refresh every second and check for the new records and report changes back to the parent.

What are you using this for? That may help in the overall solution.....

0
xboneAuthor Commented:
thanks for the fast reply.

Well it would be good to launch a page somewhere off the screen, not visible and to check each second for mysql records. If the number of rows in the mysql database is greater then the previous counted (one second ago) then it must alert the parent screen that there has been a change or refresh the parent itself too.

So in short, the parent must print off every new number of rows in the database. So if after 5 seconds there are no new records, the parent may not refresh. If there are new records, the window off the screen must tell the parent to refresh because there are new records. Do you understand?... Just let the parent refresh when the child is getting a greater amount of rows in the mysql database.

Let me know. Thanks in advance.
0
bolesjCommented:

i tottaly understand. But i was referning to more of an idea of what exactly this is used for. Is it used by administrators to view database changes or for the gen public.

If for public use: Most users (myself included) hate when windows are loaded off the screen unless i am told why beforehand. but from it looks like you need this parent and off screen child should work well.



as far as the child goes u can use the sessions but for just one trivial value on one page i wouldnt bother..just have your reload do somethign like this

<script>
window.setTimeout("location='child.php?numRows=<?MYSQLNumberRows?>'
</script>

then on the php side check to see if current number MYsqlRows == numRows from the query string. If it doesnt send the child window something like

if (quertString("numRows")!=MYSQL_num_rows($result))
{
echo " parent.refresh()";
}
else
{//nop - rows didnt change since last reload}

0
xboneAuthor Commented:
with this situation, my cursor is in wait mode and immediately back to default mode, when the child (popup) window is reloading each second (NOT refresh).

this happens only in netscape. Netscape seems to not understand that refresh != reload.

When you refresh in IE, the page refreshes and the mouse cursor is changing.. when you reload, the cursor is not changing in wait mode.

Is there any solution to keep the mouse in the default mode? Because the wait mode may not be used on my pages.. Got an idea for netscape/mozilla? ;-) thanks in advance
0
bolesjCommented:


the parent should not show any behavior related to the child. the parent should never 'talk' to the child. And the child shoud never talk to the parent UNLess to tell parent.refresh()

setting <body style="{cursor:normal}"> might work but not sure

0
xboneAuthor Commented:
I does not work... Again, it works all fine in Internet Explorer, but in Netscape/Mozilla the cursor is changing every second back to wait mode on the parent screen!

This is the PHP page which will launch the POPUP:

<?
        echo "
        <html>
        <head>
        <script>
        function popup() {
                check=window.open(\"check2.php\", \"opener\", 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=1,height=1,left=0,top=0');
        }
        function Maximize()
        {
                popup();
                parent.window.moveTo(0,0);
                parent.window.resizeTo(screen.availWidth,screen.availHeight);
        }
        </SCRIPT>
        </head>
        ";

        echo "<body style=\"{cursor:normal}\" onLoad=\"Maximize()\">";
        echo "here buttons :-)";

        echo "<br><br><a href=javascript:parent.window.close();>Close</a>
        </body>";

?>



This is the popup itself, the code:

<?
session_start();
include('config.php');

echo "
        <html>
        <head>
        <script>
        function Reload()
        {
                window.location.reload(true);
        }
        function DoReloadPage()
        {
                clearTimeout();
                setTimeout('Reload()',1000);
        }
        </script>
        </head>
        <body onLoad=\"DoReloadPage()\">
<base target=\"_self\">
";
if(! isset($counter))
{
        $counter=mysql_num_rows(mysql_query("select * from ip"));
        session_register("counter");
}
if($counter != mysql_num_rows(mysql_query("select * from ip")))
{
        if($counter < mysql_num_rows(mysql_query("select * from ip")))
        {
                echo "<script>
                parent.opener.location.reload(true);
                </script>";
                $counter=mysql_num_rows(mysql_query("select * from ip"));
                session_register("counter");
        }
}

echo "
</body>
</html>
";

?>


As you can see, i try to reload the page every second... its in a popup.. so the cursor will change every second, no problem i minimize it  and it works fine on the parent screen in internet explorer, try the same thing in netscape or mozilla, your cursor is always loading every second.. is that a bug or so? How to solve the problem ? Really, IE works fine with it, but netsheep must also work with it.. any CSS or other solution? ;)
0
bolesjCommented:

have you thought about an applet?
0
xboneAuthor Commented:
what kind of applet should i make?... i don 't know how to make it. Can you make a little example maybe? ;-) I think there are lots of people who have this problem like me and want a solution.. let me know ;-) thanks in advance
0
bolesjCommented:
Well the entire problem you are facing is because you want real-time stats on an HTML page. HTTP Client/server architectures with server side scripting are not going to provide you with this type of functionality. There are ways around it and tricks to come close but you will have to make a couple sacrifices. Such as short delays (1 second in your case) and UI things such as the cursor issue.

With an applet you have a program embedded in your web page that access the database sever from the client pc. I have written a few applets in my time but do not normally like them. You may also look into Flash. It is also an embedded object it can perform some tasks that may help you.

There is no 5-minute solution to what you want to do (that i have seen).  As far as the applet, google 'java applet tutorials' and go from there. As far as flash: see if there is a way that you can load the status page into a flash text box and then go from there.


Btw: again what are you trying to do this?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jaysolomonCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: bolesj {http:#8137621}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jAy
EE Cleanup Volunteer
0
SimianStarCommented:
if you only need a boolean result.. why dont you set an image such that

<img src="yourphpcode.php" id=imgMySQL style="visibility: hidden;display: none;">

then in your javascript code you should write your timeout to set a new src for the img.
well the same source.

     obj = getobject('imgMySQL');   <---- or whatever your function to return the right object handle is...

     obj.src = "yourphpcode.php"

in your php code for the image you simply need to check the database.
if there has been a new record then return a broken image .. ie. dont send header info for the image.
or if there has been no record,  return just a workable image.

OR.. return an image of a certain width/length.. say 100px for a new record. 50 for no new record

then in your javascript timeout.. you can include a test to see what the image contains.
 you could check the image properties for the size / if its a broken img.
then act on the results.

ive only just thought of this as a solution to the same problem im having.
i did a quick test and it doesnt seem to change the mouse. or make the annoying click occur.
I could be wrong.
give it a go. Im going to
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.