Hi,
The problem with Javascript, is that it has to load the page first - to run the code. So what you are in fact doing, is loading the NORMAL page first, and then re-directing to the new mobile version.... so that would be pretty slow. If you are using "real" static files, then it may be worth looking at some rewrite rules in a .htaccess file to do the magic:
http://ohryan.ca/...te-rules-simplified/ So something like:
Code:
RewriteEngine On
# if the browser accepts these mime-types, it's definitely mobile, or pretending to be
RewriteCond %{HTTP_ACCEPT} "text\/vnd\.wap\.wml|application\/vnd\.wap\.xhtml\+xml" [NC,OR]
# a bunch of user agent tests
RewriteCond %{HTTP_USER_AGENT} "sony|symbian|nokia|samsung|mobile|windows ce|epoc|opera" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "mini|nitro|j2me|midp-|cldc-|netfront|mot|up\.browser|up\.link|audiovox"[NC,OR]
RewriteCond %{HTTP_USER_AGENT} "blackberry|ericsson,|panasonic|philips|sanyo|sharp|sie-"[NC,OR]
RewriteCond %{HTTP_USER_AGENT} "portalmmm|blazer|avantgo|danger|palm|series60|palmsource|pocketpc"[NC,OR]
RewriteCond %{HTTP_USER_AGENT} "smartphone|rover|ipaq|au-mic,|alcatel|ericy|vodafone\/|wap1\.|wap2\.|iPhone|android"[NC]
RewriteRule ^(.*)$ http://m.yoursite.com/$1 [R=302,L]
Then setup that sub-domain on your site, and create the following extra mod_rewrite rules in that new sub-domain:
Code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !\.(jpg|gif|js|css|xml|png|php|cgi|pl|JPG|GIF|BMP|flv|swf|xml)$
RewriteRule ^(.*).html /full/path/to/live/site/cgi-bin/page.cgi?g=$1.html;t=mobile [L]
RewriteCond %{REQUEST_FILENAME} !\.(jpg|gif|js|css|xml|png|php|cgi|pl|JPG|GIF|BMP|flv|swf|xml)$
RewriteRule ^(.*).cgi /cgi-bin/$1.cgi?$1;t=mobile [L]
Totally untested, but hopefully it will get you on the right track. I can't really offer much more help, apart from doing it as a paid job
Cheers
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work! Want to give me something back for my help? Please see my
Amazon Wish List GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500) Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin |
Pre-Made Template Sets |
FREE GLinks Plugins! Compare our different Plugin packages *new* Free CSS Templates