Closed Thread
Thread Tools Search this Thread
Unread 28th Feb 2011, 04:44 AM   #1
Active Warrior
 
Join Date: 2008
Location: , , United Kingdom.
Posts: 84
Thanks: 3
Thanked 12 Times in 9 Posts
Default
Having Problems With Javascript Redirect
Share on: 
fb share twitter share gplus share more share

Hi Everyone

I have created a mobile friendly site for myself and want to redirect visitors if they find it with a resolution of more than 600 pixels to my main site.

The script I'm using is this:

<script language="javascript">
var width = screen.width;
if (width >=600) {window.location='
http://mysite.com/'}
</script>

I have placed this code between the <head> and </head> tags but the screen if anything refreshes but does not redirect.

Hope you get the gist and can help

Thanks

Chris

Get your affiliate marketing business off to a good start, visit Secret Affiliate Cash and pick up your Free Affiliate Marketing Report.
Christopher Raine is offline  
Unread 28th Feb 2011, 04:49 AM   #2
The Grand Master
 
Join Date: 2011
Posts: 39
Thanks: 1
Thanked 4 Times in 4 Posts
Default
Re: Having Problems With Javascript Redirect
Share on: 
fb share twitter share gplus share more share

Some mobile phones are not compatible with java script, try it on some other mobile phones and see the effect.

pc101seo is offline  
Unread 28th Feb 2011, 05:07 AM   #3
Active Warrior
 
Join Date: 2008
Location: , , United Kingdom.
Posts: 84
Thanks: 3
Thanked 12 Times in 9 Posts
Default
Re: Having Problems With Javascript Redirect
Share on: 
fb share twitter share gplus share more share

Hi pc101seo

This issue is if some one found my mobile site via conducting a search from their desktop. If this occurs it should direct them to my main site. If some one finds my mobile site through their mobile the site is coded to be optimized for mobile viewing with all the top mobile variants on the market today!

Chris

Get your affiliate marketing business off to a good start, visit Secret Affiliate Cash and pick up your Free Affiliate Marketing Report.
Christopher Raine is offline  
Unread 28th Feb 2011, 01:53 PM   #4
New Warrior Member
War Room Member
 
cfountain's Avatar
 
Join Date: 2005
Location: Kansas City, USA
Posts: 21
Thanks: 2
Thanked 2 Times in 2 Posts
Default
Re: Having Problems With Javascript Redirect
Share on: 
fb share twitter share gplus share more share

Chris

The line break in the window.location redirect does cause a JS error. Be sure that the command is all on one line.

if (width >=600) {window.location='http://mysite.com/'}

If that does not fix your problem, it is possible that there is another Javascript error somewhere else on the page. It may not even be related to particular script.

Open up your browser error console and look for errors. I recommend using Firefox for your Javascript code testing. To open the error console in FF use the following menu option: Tools->Error Console

-Clint
cfountain is offline  
Unread 2nd Mar 2011, 04:51 PM   #5
Active Warrior
 
Join Date: 2008
Location: , , United Kingdom.
Posts: 84
Thanks: 3
Thanked 12 Times in 9 Posts
Default
Re: Having Problems With Javascript Redirect
Share on: 
fb share twitter share gplus share more share

Originally Posted by cfountain View Post

Chris

The line break in the window.location redirect does cause a JS error. Be sure that the command is all on one line.

if (width >=600) {window.location='http://mysite.com/'}

If that does not fix your problem, it is possible that there is another Javascript error somewhere else on the page. It may not even be related to particular script.

Open up your browser error console and look for errors. I recommend using Firefox for your Javascript code testing. To open the error console in FF use the following menu option: Tools->Error Console

-Clint
Hi Clint

It works fantastic!!

Many Thanks

Chris
Christopher Raine is offline  
Closed Thread


Bookmarks

Tags
javascript, problems, redirect

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

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




All times are GMT -6. The time now is 07:23 AM.