473,320 Members | 1,744 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

WAP redirection without using PHP / ASP / ASP.NET

Hi there.

My goal is to add some script to my home page (which is NOT asp / aspx
page, and it is not hosted in IIS) so that any request from mobile
browser will be redirect to another page (a wap page which uses asp.net
mobile control page). How can I do that?

Originally, I planned to use Javascript to do it.

<script language="javascript">
var agt = navigator.userAgent.toLowerCase();
var is_mobile = ( (agt.indexOf("blacknerry") != -1)
|| (agt.indexOf("nokia") != -1)
|| (agt.indexOf("WebtV") != -1)
|| (agt.indexOf("windows ce") != -1)
|| (agt.indexOf("microsoft pocket internet explorer") != -1)
|| (agt.indexOf("up") != -1)
// more different mobile browser user agent here.

);
var mobile_url = "http://wap.mydomain.com";
if (is_mobile)
window.location = mobile_url;

</script>

It worked with Pocket PC IE, but it didn't work with BlackBerry browser
(emulator).

I suspect that it's because the blackberry browser doesn't understand
javascript. Is that true? If it is the case, it probably won't work for
other mobile browser too.

Is there a better solution to this problem?

Thanks
Dom

Nov 30 '05 #1
3 6985
do****@hotmail.com wrote:
My goal is to add some script to my home page (which is
NOT asp / aspx page, and it is not hosted in IIS) so that
any request from mobile browser will be redirect to another
page (a wap page which uses asp.net mobile control page).
How can I do that?
Redirecting with client-side scripts is generally considered the worst
method available. It certainly is not reliable.
Originally, I planned to use Javascript to do it.

<script language="javascript">
var agt = navigator.userAgent.toLowerCase();
The userAgent string is a reflection of the browser's User-Agent header,
and HTTP 1.1 specifies the User-Agent header in a way that precludes it
being regarded as a source of information. (That is, this strategy is
predicated upon a false assumption.)
var is_mobile = ( (agt.indexOf("blacknerry") != -1)
|| (agt.indexOf("nokia") != -1)
|| (agt.indexOf("WebtV") != -1)
This condition can never be true as your string contains only lower case
letters as a result of the use of - toLowerCase -.
|| (agt.indexOf("windows ce") != -1)
|| (agt.indexOf("microsoft pocket internet explorer") != -1)
|| (agt.indexOf("up") != -1)
You are going to regard any userAgent string that contains the character
sequence 'up' as a mobile?
// more different mobile browser user agent here.

);
var mobile_url = "http://wap.mydomain.com";
if (is_mobile)
window.location = mobile_url;

</script>

It worked with Pocket PC IE, but it didn't work with
BlackBerry browser (emulator).

I suspect that it's because the blackberry browser doesn't
understand javascript. Is that true?
I don't know. It may be incapable of interpreting javascript, or its
interpreter may be disabled by default (either are common with embedded
browsers).
If it is the case, it probably won't work
for other mobile browser too.
Yes, it won't work with many embedded browsers, including the ones that
spoof IE in their UA strings.
Is there a better solution to this problem?


Content negotiation on the server, as per HTTP 1.1 (RFC 2616) (so not a
javascript question). You serve WAP pages to browsers that send Accept
headers expressing a preference for them. Mobile browsers that support
WAP can be expected to do that.

Richard.
Nov 30 '05 #2
Thank you, Richard, for your answer. Yes, there were some mistakes in
my original script, but you got my idea.

Could you please eleborate your suggestion (content negotiation) a bit
more? I'm not familiar in this topic. In particular, what do I exactly
need to do on my home page to redirect the WAP request? Do I need to
change some settings in the web server (or something like that)?

How do I specify the URL that handles WAP request?

Thanks again
Dom

Nov 30 '05 #3
On 29 Nov 2005 16:08:05 -0800, do****@hotmail.com wrote:
Hi there.

My goal is to add some script to my home page (which is NOT asp / aspx
page, and it is not hosted in IIS) so that any request from mobile
browser will be redirect to another page (a wap page which uses asp.net
mobile control page). How can I do that?

Originally, I planned to use Javascript to do it.

<script language="javascript">
var agt = navigator.userAgent.toLowerCase();
var is_mobile = ( (agt.indexOf("blacknerry") != -1)
|| (agt.indexOf("nokia") != -1)
|| (agt.indexOf("WebtV") != -1)
|| (agt.indexOf("windows ce") != -1)
|| (agt.indexOf("microsoft pocket internet explorer") != -1)
|| (agt.indexOf("up") != -1)
// more different mobile browser user agent here.

);
var mobile_url = "http://wap.mydomain.com";
if (is_mobile)
window.location = mobile_url;

</script>

It worked with Pocket PC IE, but it didn't work with BlackBerry browser
(emulator).

I suspect that it's because the blackberry browser doesn't understand
javascript. Is that true? If it is the case, it probably won't work for
other mobile browser too.

Is there a better solution to this problem?

Thanks
Dom


Do not count on WAP browsers in general to support Javascript.
If all your clients support WMLscript, you could look that up.
I think you want to look up the WURFL list of which handsets support
which capabilities.
And your script tag should have " type=text/javascript' "

---Bruce Wisentaner

Dec 11 '05 #4

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

Similar topics

5
by: Jerry | last post by:
Hi All I would very much appreciate your help: I have two scripts alternating in the background triggering themselves mutually. Here is how: 1.) Script A does something and then calls Script...
52
by: Gerard M Foley | last post by:
Can one write a webpage which is not displayed but which simply redirects the user to another page without any action by the user? Sorry if this is simple, but I am sometimes simple myself. ...
15
by: Taki Jeden | last post by:
Hello everybody Does anybody know why w3c validator can not get pages that use 404 htaccess redirection? I set up two web sites so that clients request non-existent urls, but htaccess redirects...
8
by: Sullivan WxPyQtKinter | last post by:
I am now programming python scripts for CGI environment. The redirection has been discussed in this forum for over one hundred times. I have seen most of them, but still have some questions: 1....
8
by: Luciano A. Ferrer | last post by:
Hi! I was following the http://www.seomoz.org/articles/301-redirects.php article, trying to do that with one of my test sites I added this to the .htaccess file: RewriteEngine On RewriteCond...
13
by: souissipro | last post by:
Hi, I have written a C program that does some of the functionalities mentionned in my previous topic posted some days ago. This shell should: 1- execute input commands from standard input,...
4
by: psual | last post by:
hi newbie in web design I got some issue concerning a secure redirection between 2 pages let say I have a page with a grid (the 'master' page) in this grid I can select a record, get its pk...
1
by: Mike Hofer | last post by:
I really need some help, and I'd appreciate any that you folks can provide. The ASP.NET application in question uses version 1.1 of the .NET Framework. All of the pages use a common base class...
3
by: postindex | last post by:
Can I get whole commandline not only argument list. 1. When I command like this $ a.py filename 2. sys.argv is returns only argument list Is there a way to find out 'redirection'...
4
by: Neil Gould | last post by:
Anthony Jones wrote: That it is awaiting user action. Since a While/Wend or some other on-going background activity of a script appears to provide exceptions to the above statement, your usage...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.