Solved

Help needed with location.replace

Posted on 2013-05-27
2
206 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
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

786 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