Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > WAP redirection without using PHP / ASP / ASP.NET

Reply
Thread Tools

WAP redirection without using PHP / ASP / ASP.NET

 
 
domtam@hotmail.com
Guest
Posts: n/a
 
      11-30-2005
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

 
Reply With Quote
 
 
 
 
Richard Cornford
Guest
Posts: n/a
 
      11-30-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) 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.


 
Reply With Quote
 
 
 
 
domtam@hotmail.com
Guest
Posts: n/a
 
      11-30-2005
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

 
Reply With Quote
 
B Wisentaner
Guest
Posts: n/a
 
      12-11-2005
On 29 Nov 2005 16:08:05 -0800, (E-Mail Removed) 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Training Institute In Delhi, Live Projects on PHP. Short TermPHP Courses, PHP Scripts, PHP Training with Live Projects. Rajive Narain Java 0 09-18-2009 10:47 AM
WAP secure, what about WAP keys in wireless settings? Jac Wireless Networking 1 02-11-2006 04:54 AM
WAP redirection without using PHP / ASP / ASP.NET domtam@hotmail.com ASP .Net Mobile 2 11-30-2005 06:53 PM
how to use PHP to print an image for WAP Buzz XML 0 10-03-2005 07:44 AM
Help Reqd: WAP payment gateway, premium SMS and WAP usernames Aaron Whiffin HTML 0 09-04-2003 10:39 AM



Advertisments