Solved

Help needed with location.replace

Posted on 2013-05-27
2
216 Views
Last Modified: 2013-05-28
I'm trying to direct a visitor's browser to a page called resform-mobile.htm, if the visitor's device is mobile.  My code isn't working -- the wrong page is loaded.

<script type="text/javascript">
if(TestforTouchScreen() )
{document.write ('location.replace("https://secure.mauitradewinds.com/TransMan/resform-mobile.htm")');}
</script>

The page which is supposed to perform the location.replace is http://mauitradewinds.com/Test/resform-redirect-test.htm  Please advise.
0
Comment
Question by:ddantes
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 26

Accepted Solution

by:
arober11 earned 500 total points
ID: 39200083
Start by temporarilt sticking an : alert("Mobile device");  at the start of the location replace block, and see if TestforTouchScreen() is firing correctly.

Also worth a try:

{
    alert("Mobile device"); 
    window.location = "https://secure.mauitradewinds.com/TransMan/resform-mobile.htm";
}

Open in new window

0
 

Author Closing Comment

by:ddantes
ID: 39200443
Thanks!
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question