You Are Here:

Community: Developer Discussion Boards

#1 Old JavaScript problem - 1970-01-01, 02:00

Join Date: Mar 2003
Posts: 10
arunoday
Offline
Registered User
Can't I use JavaScript in XHTML - i've been using the script below in head section but it doesn't seem to work. I've tried using it in body also but it doesn't work there also.

Is JavaScript not supported - or what extra do i need to do?

I'm using Nokia Mobile Internet Toolkit 3.1 to test and develop - Also, will the code that I write here give problems with Nokia 7650 phone.

Code--


<!--

var strNav = navigator.userAgent;
//alert(strNav);

if((strNav.indexOf("Nokia&quot>-1) | (strNav.indexOf("Toolkit&quot>-1) | (strNav.indexOf("XHTML&quot>-1))
{

window.location="index.xhtml";

}

//-->

If this doesn't work then how do i redirect a page depending on the requesting device and OS like if it is from a PC or Handheld etc..
Reply With Quote

#2 Old RE: JavaScript problem - 1970-01-01, 02:00

Join Date: Mar 2003
Posts: 67
Location: Tampere, Finland
mikaaho
Offline
Regular Contributor
Hi,

You can use JavaScript, but only terminal that currently supports it is Nokia 9210i. It is possible to download a web browser (http://www.reqwireless.com/webviewer.html) for 7650, but as far as I know, it does not support JavaScript. You can however test the XHTML pages which has JavaScript content in desktop web browser.

If you have a web server running and would like to use ASP, here's a simple code how to redirect the user to wml/html page depending on the HTTP_ACCEPT environment variable.

<%
if InStr(Request.ServerVariables("HTTP_ACCEPT&quot, "wml&quot then
Response.Redirect("wml_page_here.wml&quot
else
Response.Redirect("html_page_here.html&quot
end if
%>

The code assumes that the keyword "wml" is included in the MIME type strings (like text/vnd.wap.wml etc.). The MIME types must be set on the web server in order to make this work.

User's browser can be identified from the HTTP_USER_AGENT -field:
...
If InStr(Request.ServerVariables("HTTP_USER_AGENT&quot, "Nokia&quot then
Response.Redirect("nokia.wml&quot
...

Hope this helps,
Mika / Forum Nokia Developer Support
Reply With Quote

#3 Old RE: JavaScript problem - 1970-01-01, 02:00

Join Date: Mar 2003
Posts: 10
arunoday
Offline
Registered User
since JavaSCript support is not there in all the mobile browsers so it is better to avoid using JS for page redirecting - it can be achieved by using inherent properties or methods of the scripting language being used - say redirect in ASP, header("Location: url" in PHP or sendRedirect in servlets or JSP.
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia