ReMuSoMeGa Posted September 12, 2007 Share Posted September 12, 2007 I need a script, that will let me flash a message on the viewer's browser. I need to be able to set how long the text will stay there, like even less than a second. I need it to be displayed in a random place on the screen. Im farily new to ajax, but I have experience with it. Any help will be appreciated, Thanks -Remus Link to comment https://forums.phpfreaks.com/topic/69052-using-ajax-to-flash-a-message-in-browser/ Share on other sites More sharing options...
ariel_ro Posted September 12, 2007 Share Posted September 12, 2007 you need to trigger a javascript function using an event like onload(if you want the message to appear when the user first enters the page). Then a <div></div> tag containing the message should be rendered by a server-side page(php/asp) that will be opened by the javascript xmlHttp object. The random position can be achieved in various ways depending on each browser. if this sounds a little bit tricky take a look at ajax right here: http://w3schools.com/ajax/default.asp Link to comment https://forums.phpfreaks.com/topic/69052-using-ajax-to-flash-a-message-in-browser/#findComment-347109 Share on other sites More sharing options...
ReMuSoMeGa Posted September 12, 2007 Author Share Posted September 12, 2007 ye I understand basic ajax stuff like that, but I don't know how to make it appear in a random spot on your screen, and make it disapear in a fraction of a second Link to comment https://forums.phpfreaks.com/topic/69052-using-ajax-to-flash-a-message-in-browser/#findComment-347117 Share on other sites More sharing options...
ScotDiddle Posted September 12, 2007 Share Posted September 12, 2007 ReMuSoMeGa, You might want to look at the overLib Javascript solution... http://www.bosrup.com/web/overlib/?Command_Reference :: Specifically the the TIMEOUT parm and the FIXX / FIXY parms... The location parms could be generated via javascript or server-side (PHP / ASP) functions before the call to overLib is built. See my post earlier today pertaining to overLib here: http://www.phpfreaks.com/forums/index.php/topic,157902.0.html Scot L. Diddle, Richmond VA Link to comment https://forums.phpfreaks.com/topic/69052-using-ajax-to-flash-a-message-in-browser/#findComment-347129 Share on other sites More sharing options...
ReMuSoMeGa Posted September 13, 2007 Author Share Posted September 13, 2007 Sorry, but that really dosnt help me. I need to be able to flash messages on random parts of the screen in intervals Link to comment https://forums.phpfreaks.com/topic/69052-using-ajax-to-flash-a-message-in-browser/#findComment-347831 Share on other sites More sharing options...
ariel_ro Posted September 18, 2007 Share Posted September 18, 2007 I left the city for a few days and now i'm able to read the post. I worked a quick code that makes a pop-up appear random between 0px and 300 and dissappear after 1 sec. Refresh the page to see different positions of the div. Hope it helps you! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <style> .Div { position:absolute; width:150px; height:30px; background-color:#666666; display:none; } </style> </head> <body onload="Start();"> <div id="myDiv" class="Div">Some text goes here</div> <script language="javascript"> var t; var k=0; var n=Math.floor(Math.random()*300); var obj = document.all? document.all.myDiv : document.getElementById("myDiv"); function makeTo() { k++; obj.style.left=n+"px"; obj.style.top=n+"px"; obj.style.display="block"; if(k>10) { obj.style.display="none"; clearInterval(t); } } function Start() { t=setInterval('makeTo();',100); } </script> </body> </html> Link to comment https://forums.phpfreaks.com/topic/69052-using-ajax-to-flash-a-message-in-browser/#findComment-350382 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.