JavaScript - Need Help With Mobile Redirect & :view Desktop Site
I am making a site HERE and I was using this:
Code: <script> if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile/i.test(navigator.userAgent)) { if (document.URL != "http://www.precisionpaintandcollision.net") { window.location = "http://m.precisionpaintandcollision.net"; } } </script> to auto-redirect mobile users to the mobile site and I want to keep that but I want them to be able to view the desktop site without that code affecting them. I know some apps have "force/request desktop site" but i'd like them to be able to just view the desktop site without auto redirecting to mobile site. Is this possible? Thanks -John Similar TutorialsIs it there way to set desktop background picture from web page? For example, i have wallpaper.php and there 6 wallpapers, is there javascript to install them directly pb click something on page? Like install button?
Code: document.getElementById('desktop').onclick = "javascript:alert(1);"; getting very very annoyed at javascript!!! Why doesn't this work!? I am using the following code for my iframes: Code: <iframe frameBorder="0" height="100%" width="100%" src="http://the.url.com"></iframe> However, when you go to my Desktop sample and click on any of the icons it doesn't load the iframe at 100% height for some reason. You can see that he Code: http://www.zazavi.com/desktop/desktop.html If anyone could tell me what I am doing wrong, it would be greatly appreciated. Thanks for your time! Several of the iPhone features can be duplicated with Javascript. One such feature I'd like to see is the Bookmark feature. You click on the Bookmark or Favorite button and the page name (of the html page) is saved to a list, just like what you see in modern browsers. Clicking on the list row brings up the bookmarked page. However, the app is not a browser, but made up of html/css/js pages that function from within a /www/ folder of the app. I've searched for such a script online, but the only ones I see are for desktop browsers (they permit a visitor to click on a link to place the page in the Bookmarks tab or folder of the browser). Does anyone know of a script that'll work on html pages in the iPhone and Android devices? Thanks! Steve Similiar to that of CBS.com or AOL.com when you visit them on the iphone. Something that responds to the swipe gesture within the iphone. I've been searching google, but mobile web resourses are far and few. Also tried to check out their source and it only shows it as one long line of text, not ideal for trying to read code. Hey, I'm working on a mobile website and need some help with my mobile browser detection script. I have it working for iPhone, iPod Touch, and Windows Mobile Devices. I need help getting it to detect for Blackberry Browser (Blackberry Devices), Blazer Browser (Palm Devices), Opera Mini Browser, Opera Mobile Browser, and other mobile browsers if possible. Does anyone know how to modify (and test if you have a phone to test with, as I don't have all of these devices) this javascript?: Code: if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {location.replace("mobile.html");} if((navigator.appVersion.indexOf("Windows CE")>0)) {location.replace("mobile.html");} Thanks for your help! -Chris I want to disable modal box when the page it is attached to is being viewed on a mobile device. I have tried what I know and have crashed and burned. Help will be greatly appreciated. This is the code that I have use... Code: <script src="/o/4055/images/jquery.avgrund.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { $(".hidden").avgrund({ width: 500, // max is 640px height: 340, // max is 350px showClose: true, // switch to 'true' for enabling close button showCloseText: 'close', // type your text for close button closeByEscape: false, // enables closing popup by 'Esc'.. closeByDocument: true, // ..and by clicking document itself enableStackAnimation: false, // another animation type onBlurContainer: 'div#container', // enables blur filter for specified block template: '<div style="margin: 0 auto; padding:0; width:500px; height:350px;">' + '<a href="https://afl.salsalabs.com/o/4055/p/salsa/donation/common/public/?donate_page_KEY=7606" style="border:none;" target="_blank"><img src="http://i1298.photobucket.com/albums/ag60/ProdSolutions/Lightbox_1_zpscead0a26.jpg" width="500px" height="350px" /></a>' + '</div>', onUnload: function() { var date = new Date(); date.setTime(date.getTime() + (1 * 24 * 60 * 60 * 1000)); $.cookie("ARA_October_2014","true",{path:"/",expires:date}); } }); $(".hidden").trigger('click'); }); $("#submitContribution").attr('value', 'Donate Now'); $("label[for=cc_number]").after($('div#useCC fieldset#credit_card_information div.formRow div.helpText')); $("#credit_card_information > div:nth-child(6) > label:nth-child(1) > a:nth-child(1)").before($('#CVV2')); $('#personal_information > legend:nth-child(1)').each(function() { var text = $(this).text(); $(this).text(text.replace('Your Information', 'Your Billing Information')); }); $('div.formRow:nth-child(19) > label:nth-child(1)').each(function() { var text = $(this).text(); $(this).text(text.replace('Phone', 'Your Phone')); }); $('#credit_card_information legend').each(function() { var text = $(this).text(); $(this).text(text.replace('Credit Card Information', 'Payment Information')); }); $('#credit_card_information > div:nth-child(3) > label:nth-child(1)').each(function() { var text = $(this).text(); $(this).text(text.replace('Card Number', 'Credit Card Number')); }); $('#submit > p:nth-child(2)').each(function() { var text = $(this).text(); $(this).text(text.replace('Please click the submit button only once.', 'Please click this button only once.')); }); $('.readMore').click(function(){ $('.readMore').hide('slow'); $('.text2').show('slow'); }); </script> I'm trying to create a mobile app for an internet station, and right now I'm just trying to get how to get it to play. I've got it to connect to an MP3 file and it works just like I want it to. However, upon setting it to connect to the stream, it returns with "java.io.IOException: failed to connect to http://71.127.84.92:8004 : response does not start with HTTP it starts with: ICY" Here is the code: Code: public void commandAction(Command command, Displayable displayable) { if (command == stopButton){ if (isPlaying == true) { try { Remedy.stop(); Remedy.close(); } catch (MediaException pe) {System.out.println(pe); } finally { isPlaying = false; mMainForm.removeCommand(stopButton); mMainForm.addCommand(playButton); } } } else if (command == playButton) { try { Remedy = Manager.createPlayer("http://71.127.84.92:8004"); //This is the URL causing the error Remedy.start(); System.out.println("Done"); } catch (MediaException pe) { System.out.println(pe); } catch (java.io.IOException ioe) { System.out.println(ioe); } finally { isPlaying = true; mMainForm.removeCommand(playButton); mMainForm.addCommand(stopButton); } } else { System.out.println("Exiting..."); notifyDestroyed(); } } Can anyone help me get it to play the shoutcast stream? Any help would be greatly appreciated, I am a Java noob. Is there a way that we can Disable Panning in Fennec, or Mobile Chrome (on android devices). The Panning, and inertial scrolling effects that are part of the browser are interfering with being able to get the mouse position. I would like to use DHTML paint on my Google Android MID.... i really have no idea where to start.. Im working on a mobile site for a friend and im curious, can i trigger javascript events on screen flick (By flick i mean the way to scroll through homepage screens). Id love to run a few things like that but i dont know if thats possible. If it is is there a tutorial about i could look at?
I am in a Mobile App Dev class. Our current project is to create a webapp that allows a user to search for zip,city,etc and get back weather and news. I am having some issues in that my code is not working. Anyone have a moment to check it out? Quote: <!-- --> <!DOCTYPE html> <html lang="en-us"> <head> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.css" /> <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.3.min.js"></script> <script type="text/javascript" src="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.js"></script> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <script type="text/javascript"> function geo() { navigator.geolocation.getCurrentPosition(function(position) { do_something(position.coords.latitude, position.coords.longitude);}); } function top_stories(o) { var items = o.query.results.item; var output = ''; var no_items=items.length; for(var i=0;i<no_items;i++) { var title = items[i].title; var link = items[i].link; var desc = items[i].description; output += "<h3><a href='" + link + "'>"+title+"</a></h3>";// + desc + "<hr/>"; } // Place news stories in div tag document.getElementById('results').innerHTML = output; } function cb_weather(yql) { var temp = yql.query.results.channel.item.description; var region = yql.query.results.channel.location.city +", "+ yql.query.results.channel.location.region; document.write("<H3>"+ region +"</H3>" +temp); } function save(zipcode) { localStorage.zipcode = zipcode.value; alert("Zip code is " + localStorage.zipcode); } </script> <title>Mobile Local</title> </head> <body> <div data-role="page" id="menu"> <div data-role="header" data-theme="b"> <h1>Mobile Local</h1> <a data-role="button" class="ui-btn-left" onclick="geo();">Locate Me!</a> </div> <div data-role="fieldcontain" data-inline="true"> <label for="name">Enter your location:</label> <input type="text" name="zipcode" id="zipcode" value="" /> <a data-role="button" onclick="save(zipcode); return false;" value="Save Data" />Search</a> </div> <div data-role="content" id='weather'> <script id="weather" src='http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20location%3D02446&format=json&callback=cb_weathe r'></script> </div> <div data-role="content" id='results' onload="geo()"> <script src='http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20rss%20where%20url%20%3D%20"http%3A%2F%2Fnews.google.com%2Fnews%3Fgeo%3D024 46%26output%3Drss"&format=json&diagnostics=true&callback=top_stories'></script> </div> </div> </body> </html> http://mybestmaterial.blueeyedpandahosting.com/cep/1/ Works exactly as expected (and all the code is built into the source code view of the page.) What happens is 2 timers are set up. 1 is running when user clicks the Start/Stop link. The second is started when the user clicks the Laughter Start/Stop link. So the sequence should be User -- Start click then after that -- laughter-start-stop click... You will see both timers start running. The laughter click will be clicked multiple times as the app is designed to time how much laughter a comedian or speaker is getting relative to the amount of time on stage. So click the laughter start stop multiple times before clicking the START-STOP the last time. Then a PAR score is generated - which is a simple percent of the time laughter happened, vs the time on stage. The link above works like a charm. THE PROBLEM is -- on my SPRINT TREO 700p --- when I click the laughter start/stop click it stops all the timers. I think for some reason the TREO won't allow the second NEW DATE() to be declared or something... because when I comment those two lines out --- line 166 and 167 in Dreamweaver version of the file -- (if you copy full source into dreamweaver...) Then the clicking doesnt' stop the main timer -- but it also doesn't work!! ANY THOUGHTS on how to decloare the SCOPE fo the NEW DATE() so it only effects that one function? OR any other suggestions? Code pasted below Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <title>Comedy Analyzer - Simple</title> </head> <script type="text/javascript"> var flagclock = 0; var flagstop = 0; var stoptime = 0; var currenttime; var splitdate = ''; var output; var clock; function startstop() { //var startstop = document.getElementById('startstopbutton'); var startdate = new Date(); var starttime = startdate.getTime(); if(flagclock==0) { flagclock = 1; counter(starttime); } else { if(laughter_flagclock==1) { laughter_startstop(); } flagclock = 0; flagstop = 1; splitdate = ''; //total laughter === running_total_laughter_time; //total time == running_total_time; var par_score = (Math.round(running_total_laughter_time/running_total_time*100))/100; var par_score_percent = par_score*100; //var par_score = running_total_laughter_time/running_total_time; laughter_output.value = "PAR SCORE = " + par_score_percent; } } var running_total_time; function counter(starttime) { output = document.getElementById('output'); clock = document.getElementById('clock'); laughter_output = document.getElementById('laughter_output'); currenttime = new Date(); var timediff = currenttime.getTime() - starttime; if(flagstop == 1) { timediff = timediff + stoptime } if(flagclock == 1) { clock.value = formattime(timediff,''); running_total_time = timediff; refresh = setTimeout('counter(' + starttime + ');',10); } else { //start and stop the running counter while adding the values to the next deal. window.clearTimeout(refresh); stoptime = timediff; } } function formattime(rawtime,roundtype) { if(roundtype == 'round') { var ds = Math.round(rawtime/100) + ''; } else { var ds = Math.floor(rawtime/100) + ''; } var sec = Math.floor(rawtime/1000); var min = Math.floor(rawtime/60000); ds = ds.charAt(ds.length - 1); if(min >= 60) { startstop(); } sec = sec - 60 * min + ''; if(sec.charAt(sec.length - 2) != '') { sec = sec.charAt(sec.length - 2) + sec.charAt(sec.length - 1); } else { sec = 0 + sec.charAt(sec.length - 1); } min = min + ''; if(min.charAt(min.length - 2) != '') { min = min.charAt(min.length - 2)+min.charAt(min.length - 1); } else { min = 0 + min.charAt(min.length - 1); } return min + ':' + sec + ':' + ds; } function resetclock() { if(flagclock == 1) { //alert("if side of reset clock"); var resetdate = new Date(); var resettime = resetdate.getTime(); counter(resettime); } else { //alert("ELSE side of reset clock"); clock.value = "00:00:0"; } flagstop = 0; stoptime = 0; splitdate = ''; laughter_resetclock(); window.clearTimeout(refresh); output.value = ''; } </script> <script type="text/javascript"> var laughter_flagclock = 0; var laughter_flagstop = 0; var laughter_stoptime = 0; var laughter_currenttime; var laughter_splitdate = ''; var laughter_output; var laughter_clock; var count = 0; function laughter_startstop() { var laughter_startdate = new Date(); var laughter_starttime = laughter_startdate.getTime(); if(laughter_flagclock==0) { laughter_flagclock = 1; laughter_counter(laughter_starttime); laughter_number_text = document.getElementById('laughter_number'); count++; laughter_number_text.value = count; } else { laughter_flagclock = 0; laughter_flagstop = 1; laughter_splitdate = ''; } } var running_total_laughter_time; function laughter_counter(laughter_starttime) { laughter_clock = document.getElementById('laughter_clock'); laughter_currenttime = new Date(); var laughter_timediff = laughter_currenttime.getTime() - laughter_starttime; if(laughter_flagstop == 1) { laughter_timediff = laughter_timediff + laughter_stoptime } if(laughter_flagclock == 1) { laughter_clock.value = laughter_formattime(laughter_timediff,''); running_total_laughter_time = laughter_timediff; //laughter_output.value += "-- laughter -- "+running_total_laughter_time; laughter_refresh = setTimeout('laughter_counter(' + laughter_starttime + ');',10); } else { window.clearTimeout(laughter_refresh); laughter_stoptime = laughter_timediff; } } function laughter_formattime(laughter_rawtime,laughter_roundtype) { if(laughter_roundtype == 'round') { var laughter_ds = Math.round(laughter_rawtime/100) + ''; } else { var laughter_ds = Math.floor(laughter_rawtime/100) + ''; } var laughter_sec = Math.floor(laughter_rawtime/1000); var laughter_min = Math.floor(laughter_rawtime/60000); laughter_ds = laughter_ds.charAt(laughter_ds.length - 1); if(laughter_min >= 60) { laughter_startstop(); } laughter_sec = laughter_sec - 60 * laughter_min + ''; if(laughter_sec.charAt(laughter_sec.length - 2) != '') { laughter_sec = laughter_sec.charAt(laughter_sec.length - 2) + laughter_sec.charAt(laughter_sec.length - 1); } else { laughter_sec = 0 + laughter_sec.charAt(laughter_sec.length - 1); } laughter_min = laughter_min + ''; if(laughter_min.charAt(laughter_min.length - 2) != '') { laughter_min = laughter_min.charAt(laughter_min.length - 2)+laughter_min.charAt(laughter_min.length - 1); } else { laughter_min = 0 + laughter_min.charAt(laughter_min.length - 1); } return laughter_min + ':' + laughter_sec + ':' + laughter_ds; } function laughter_resetclock() { //alert("laughter_resetclock called"); if(laughter_flagclock == 1) { var laughter_resetdate = new Date(); var laughter_resettime = laughter_resetdate.getTime(); laughter_counter(laughter_resettime); } else { laughter_clock.value = "00:00:0"; } laughter_flagstop = 0; laughter_stoptime = 0; laughter_splitdate = ''; count = 0; laughter_number_text.value = count; window.clearTimeout(refresh); laughter_output.value = ''; //window.clearTimeout(refresh); output.value = ''; } </script> <body> Running Time :: <input id="clock" type="text" value="00:00:0" style="text-align: center;" size="14"readonly><br /> Laughter Time :: <input id="laughter_clock" type="text" value="00:00:0" style="text-align: center;"size="14" readonly><br /> Laugh Count :: <input id="laughter_number" type="text" value="0" style="text-align: center;" size="4" readonly><br /> <div id="start_button"><a href="javascript:startstop();">Timing Start/Stop</a></div> <div id="laughter_start_button"><a href="javascript:laughter_startstop();">Laughter Start/Stop</a></div> <textarea id="laughter_output" style="height: 90%;" cols="40" rows="1"></textarea><br /> <a href="javascript:resetclock();">Full-Reset</a><br /><br /> </body> </html> Hi, everyone! I am a freshman in the JavaScript area. One thing i am wondering recently is that whether JavaScript can get a data from the sensors as accelerometer, gyroscope or orientation sensors of a mobile device? From as a iPhone, iPad or some other Android system mobile phones, may i just use JavaScript to get the data from their sensors? Looking forward the replies from anybody. Thanks a lot! Best regards, Borui Hey there. I've recently written a small javascript library that creates a unified interface for localStorage and sessionStorage. The code is here http://github.com/AndrewLowther/StorageItem I'm looking for people to give me feedback and to help me work on it should you so wish. Feedback is most welcome! Hello, Is there a way with JavaScript to easily detect which mobile browser is being used? I would not normally ask this, but because we do not have the time or budget to implement any back end detection scripting it is our only option right now! I don't think we will need to detect which version of the browser, or which revision of the phone is used - just need to target each family to deliver the proper video type. I manage a private website that has a normal desktop version and also an iPhone version. Both versions use jQuery. I'm wondering if I could get some help with the iPhone version. Right now, I have one of the navigation items set up so that when it's tapped on, a submenu with more navigation items appear. This is much like the "more" menu at the iPhone version of http://www.google.com/. The problem I'm having is that once that submenu is shown, the only way to make it disappear again is to tap on one of its items. I'd like to be able to tap anywhere outside of the submenu to make it disappear. This is how the iPhone version of http://www.google.com/ behaves, so I know it's possible. The only way I can think of accomplishing this is to add a click event to the body that calls a function that removes the submenu. However, I can't get it to work. At the bottom of this post you will find code that illustrates this problem. I would really appreciate any help. Thanks! Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <title>Safari Mobile Test</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"> <style type="text/css"> body { border: 1px solid red; } </style> </head> <body> <h1>Safari Mobile Test</h1> <p><a href="#">This link doesn't go anywhere. If you click it, you will get an alert indicating that the link was clicked and a separate alert indicating that the body was clicked.</a></p> <p>In a normal web browser, clicking anywhere within the body of this page (which is surrounded by a red border) will trigger an alert indicating that the body was clicked. However, the only way to see the alert using Safari Mobile is to click on the above link.</p> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('body').click(function() { alert('The body was clicked!'); }); $('a').click(function() { alert('The link was clicked!'); }); }); </script> </body> </html> Hi all, Background: I'm currently working on a landing page which will display the same on both desktop & mobile devices, which is what we "want" for now. However, we've created an alternate registration page for mobile devices. This page can be accessed by clicking on a specific button, which has a class on it that will determine if the user is on a mobile device or not. If they are not, the normal action will occur, such as a registration popup, built specifically for desktop users. The problem is: I'm firstly having to use .remove to take away the class of pbx_ajax which operates the popup, so mobile users aren't affected by the popup and will continue onto the page we specially built for them. However, it seems my script is removing the class straight away, which prevents the popup from working for desktop users. Secondly, the script doesn't actually seem to work, it simply doesn't fire, which begs the question if i've cocked up my class bind. Code is attached below, please if anyone has any advice, do let me know as i'm at my wits end. Oh and i'm sure you'll notice, i'm polling for when the jQuery has loaded, as the library is located at the bottom of our site (its a rather large site). The javascript/jquery Code: //$(document).ready(function() { //Global function that will detect what device the page is being viewed on function globalDetectDevice() { var deviceIphone = "iphone"; var deviceIpod = "ipod"; //Initialize our user agent string to lower case. var uagent = navigator.userAgent.toLowerCase(); //************************** // Detects if the current device is an iPhone or iPod Touch. function DetectDevice() { if (DetectIphone()) { window.location = "/landing/register/mobile" ; } else if (DetectIpod()) { window.location = "/landing/register/mobile" ; } else { return false; } } } //Binding the above function to a class, that we can then attach to any clickable element //As jQuery is at the bottom of page, we poll the function until jQuery has loaded, once loaded, we clear the polling using clearTimout var bindTimer = setInterval(function() { if ("undefined" != typeof jQuery && globalDetectDevice) { $('.detectDevice').removeClass('pbx_ajax').bind('click', DetectDevice); clearTimeout(bindTimer); } }, 50); //} the html button Code: <a class="detectDevice pbx_ajax" title="Join Free" href="?cat=popup&action=open&settings=pbx_popup_register">~graphic("btn-get-started-prints-LP")</a> thanks for any help What would be the best way to get data for a mobile site. I've tried using Jquery $.ajax to bring in the data from a php file. It seems to work however it takes some time to load without a way to really give a progress meter. I was wondering what the fastest way to do this would be. For instance it loads and loads then after a long while the alert(); pops up and the data loads into the page. Ultimately i was thinking i could use the ajax request to read in the data from the mysql database server, then transfer it to localstorage, im using HTML5 primarily for the development also just for reference. Somewhat new to mobile development i was just wondering if anyone had a starting point for me to look at and go from there. Code: $(document).ready(function($){ var dataret = 0; $.ajax({ type: 'POST', url: 'mobile.php', beforeSend: function(){ $('#status').show(); }, success: function(data){ //initialize localstorage here alert('success'); // if it takes as long as it does, a few minutes, at least show a loading bar... $('#progress').progressbar({ }); }, dataType: 'json' }); }); Thanks in advance! I am incorporating this menu into a site and for desktop users I need the mouseover. However, after referencing the link below for mobile devices (most management has Blackberrys). I am concerned the mouseover will not work on their phones. How do I add an option that will work on phones - like mouseover OR click option? http://www.quirksmode.org/m/table.html Thanks! |