brent123456 Posted April 21, 2008 Share Posted April 21, 2008 I want to load and image if they have dial-up or a flash movie if they have high speed. Is there anyway I can do this when the user comes to the page for the first time? I found the script below that another user had posted but I am not sure if that would work for checking dial-up vs high speed? http://www.phpfreaks.com/forums/index.php/topic,155661.0.html Thanks Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted April 21, 2008 Share Posted April 21, 2008 you can't perfectly detect a users connection speed, but basically you have to have a link that will say "high speed" or "slow speed" and it looks like <a href="setspeed.php?speed=1">High Speed</a> <a href="setspeed.php?speed=0">Slow Speed</a> and setspeed.php does <?php session_start(); $_SESSION['speed'] = $_GET['speed']; if($_SESSSION['speed'] != 1 || $_SESSION['speed'] != 0){ #Default set $_SESSION['speed'] = 1; die(header("location: Somepage.php")); ?> then anytime you go load a file you do a check such as <?php if($_SESSION['speed'] == 1){ #load high speed graphics } else{ #load slow speed graphics } ?> Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted April 21, 2008 Share Posted April 21, 2008 java/javascript is the only method you will get for detecting the current data transfer speeds - I would sggest you serve an image by defaul and use javascript to replace that with a movie if the detected transfer rate is sufficient. Quote Link to comment Share on other sites More sharing options...
monkeypaw201 Posted April 21, 2008 Share Posted April 21, 2008 java/javascript is the only method you will get for detecting the current data transfer speeds - I would sggest you serve an image by defaul and use javascript to replace that with a movie if the detected transfer rate is sufficient. So, would it be possible to set a variable with javascript? so the speed is detected in javascript and the process is the same in PHP? Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted April 21, 2008 Share Posted April 21, 2008 no - php can't do anything for you here apart from set a javascript variable with the path of the movie file. Transfer speed can only be detected client side NOT server side... Once the detection is complete if the lower threshold for you movie is exceeded then you can replace teh html of the parent element of teh img tag awith an object tag for the movie... Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted April 21, 2008 Share Posted April 21, 2008 you really shouldn't "predict" the client's speed let them say what they want cause high/low res is more a preference thing vs a client's speed. You can take the javascript result of "speed" and use ajax to push it in to the session variable, but I still think its a client's choice Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted April 21, 2008 Share Posted April 21, 2008 its no big deal cooldude... its essentially just the reverse of plugin detection - you put an image inside an object tag of a swf file - if flash is available then the swf plays if not user sees image... I actuallythink that what is being asked here is a legitamate exercise in imporving user experience - something java/javascript shoudl be used for... Quote Link to comment Share on other sites More sharing options...
jonsjava Posted April 21, 2008 Share Posted April 21, 2008 I agree. Most of the time, when visiting sites, I opt to skip the flash intro. I hate sites that make me watch their advertisement about themselves, and leave you no choice. Quote Link to comment Share on other sites More sharing options...
brent123456 Posted April 23, 2008 Author Share Posted April 23, 2008 Does anyone have a link to an example link of how to use Javascript to detect the speed? This is not for an intro page it is for the main index page of my site. I have a small movie that has pictures and updates that loads when you first come to the main page of the site. Basically I don't want it to load for dial-up users. The link idea would work for an intro page but for my main index page it would already be loading by the time the user clicks the "High Speed" or "Low Speed" links. Thanks Quote Link to comment Share on other sites More sharing options...
brent123456 Posted April 26, 2008 Author Share Posted April 26, 2008 Bump.... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.