In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "what are the JavaScript codes commonly used in the development of mobile websites?" in the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1. If the page is viewed in an iPhone or Android browser, add the "iPhone" or "Android" class name to the body element
If (navigator.userAgent.match (/ iPhone/i)) {$('body'). AddClass (' iPhone');} else if (navigator.userAgent.match (/ Android/i)) {$('body'). AddClass (' Android');}
2. Remove the browser address bar
Window.scrollTo (0,1)
3. Prevent web pages from touching and scrolling
Notouchmove = function (event) {event.preventDefault ();}.
4. Display information when browsing horizontally
Var updateorientation = function () {var classname ='', top = 100; switch (window.orientation) {case 0: classname + = "normal"; break; case-90: classname + = "landscape"; break; case 90: classname + = "landscape"; break } if (classname = = 'landscape') {if ($(' # overlay'). Length = 0) {window.scrollTo (0,1); $('body'). Append (' Landscape view is not supported for this page.');}} else {$('# overlay'). Remove ();}} Usage: var supportsOrientationChange = "onorientationchange" in window, orientationEvent = supportsOrientationChange? "orientationchange": "resize"; window.addEventListener (orientationEvent, function () {updateorientation ();}, false)
5. Display part of the description information and display the complete information when clicked
Var truncatedesc = function (trunc, len) {if (trunc) {var org = trunc; if (trunc.length > len) {trunc = trunc.substring (0, len); trunc = trunc.replace (/ wicked impulse,''); trunc ='+ trunc; trunc + = '...'; trunc + =''+ org +'' } $('.truncated') .live ("touchstart touchend", function () {$(this) .closest ('div'). Find (' .original') .show (); $(this) .closest ('div'). Find (' .truncated') .hide (); return trunc;}}; Usage: truncatedesc (item.description, 100)
6. When you receive a successful Ajax request, redirect to another page (jQuery mobile)
Var ajaxurl = 'http://...' ; / Your web service URL $.ajax ({url: ajaxurl, type: 'GET', processData: false, contentType: "application/json", dataType: "jsonp", success: function (data) {$.mobile.changePage ("results.html");}, error: function () {alert (' errorations');}})
7. Remove the active status (jQuery mobile) from the link in the list view
$('div') .live (' pageshow', function (event, ui) {$('[data-role=listview] li') .removeClass ("ui-btn-active");})
8. Disable the default jQuery mobile style (jQuery mobile) from the drop-down selection
$(document) .bind ("mobileinit", function () {$. Mobile.page.prototype.options.keepNative = "select";})
9. Dynamically update the list view (jQuery mobile)
Var output ='
'; output + =' + item.title +'; output + =''; $('# mylistul') .append (output) .listview ('refresh')
10. Dynamically add form input and apply default style (jQuery mobile)
Var html ='; $('# searchform') .append (html); $('# suburb'). Textinput (); "what are the JavaScript codes commonly used in the development of mobile websites". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.