Redirect users according to their bandwidth using Javascript

Hi

Depending on the users bandwith I have to redirect the users to different asp pages
Is there a way to find if they are using high / low bandwith and redirect accordingly in Javascript ?

Thanks

ranirajeshAsked:
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.

ethothsCommented:
There is no precise way to do it but you could try this....

1) Create a page with some javascript i the head that gets the current time.
2) As the last line in the body get the time again. The difference between the two will be a measure of how long the page took to load (and hence the bandwith).
3) Depending on the time determined in 2 redirect to the appropriate page.

This will require a little calibration to get right and the page that you use to do this will have to have some amount of content to make it take some time to load but it should work.

(Another way would be to do the same thing in AJAX. Since this is asynchronous your users should not notice any delay.
0
flipzCommented:
@ethoths - I don't believe your theory will work. Since Javascript is only processed once the code is already in the browser - calculating the time between to 'head' and 'footer' times is more a measure on how fast the client machine runs the script.

AJAX is a closer measure but again there are issues with server traffic etc. that would affect the response time and not sufficiently give you an accurate time. You could try it by taking the current time in JavaScript - place an AJAX call to an .asp page, take the time when the response is recieved - subtract the difference of the two times and subtract the processing time of the .ASP page and you will get a (somewhat inaccurate) measure of bandwith.

0
ethothsCommented:
Yes you are right, the code will run as soon as it is in the browser. The code in the head will run just after the page starts loading and the footer code when it is loaded. It's not really measuring the time it takes the page to load, rather it's taking a measure of the time elapsed between the head code loading and the footer code loading. This is somewhat related to the time that the page takes to download.

My understanding was that the requirement was to determine whether the user has a low bandwidth connection (56k Modem) or a high bandwidth 2Mb ADSL. If this is the case then there is a factor of 40 between the them. In this case accuracy is not really required. If the page loads in less than 1 second then it's ADSL, if it takes more than say 20 then it's not. A bit of imperical calibration will yeild reliable results.

I agree that the AJAX approach will yeild even better results but it might be a little overkill for a simple "go/no-go gauge".
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

flipzCommented:
ethoths - as I understand it - the actual JS code does not actually run until the page is fully loaded. Even if you put a timestamp in the head of the page - the JS call to get that time will not fire until the entire HTML is loaded into the browser. This means that any JS code running would have nothing to do with bandwith.

I agree that there is a considerable difference between dial-up and ADSL so some innacuracies are acceptable but what if a user on ADSL runs the page but the server is too busy to respond and takes 20 seconds to run? Then the client code would assume that the connection is dial-up.

In any case - ranirajesh - you're probably just better off the let the user choose their own connection speed.
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
ethothsCommented:
Yes flipz: you are correct about the running of the JS and my first suggestion would not run. My suggestion about AJAX looks like the best way.

Incidentally, the fact that a slow server or connection could result in tha inaccurate selection of page is a good thing. It does not really matter why the page is slow to load. If it is slow for any reason then the leaner version should be used.

Letting users choose has several disadvantages...

1) Some users won't know.
2) Some will choose the wrong answer
3) Some will be scared off by such a technical question.
4) It cannot dynamically auto configure
5) If the choice is perisited as a preference and the user then upgrades, they will not be getting the best experience.
0
ranirajeshAuthor Commented:
Thanks to both of you ... My mistake for not responding earlier ...  for the time being I have left the choice to the user , but in future I would definitely like to try out using AJAX
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
Microsoft Development

From novice to tech pro — start learning today.