


Implementation of page jump and loading external pages in jQuery mobile web development_jquery
changePage() page jump
jQuery.mobile.changePage( to [, options ] )
To jump from one page to another, use the changePage method of the $.mobile object. But to use this method, you have to click a link or submit a form. This method has two parameters.
to: It is the first parameter, it is necessary and indispensable. Type: string or object.
String: Absolute or relative URL address. For example: ("about/us.html")
Object:
jquery selector object, such as: ($("#about")).
An array [from, to] that specifies two page references, used to jump to a known page. From is the currently visible page (or $.mobile.activePage).
Object to send form data, such as ({to: url, data: serialized form data, type: "get" or "post"}.
options: It is the second parameter and is optional. Type: Object
allowSamePageTransition (boolean, default: false)
By default, changePage() ignores requests to jump to an already active page. If this is set to true, it will be executed. Developers should note that some page transitions will assume that the source page and the target page in a request to jump to a page are different, so there will be no transition animation.
changeHash (boolean, default: true)
Determines whether the address bar hash should be updated.
data (string or object, default: undefined)
The data to be sent via ajax request is only available when the to parameter of changePage() is an address.
dataUrl (String, default: undefined)
The URL address of the browser address is updated when the page conversion is completed. If not specified, the data-url attribute value of the page is used.
pageContainer (jQuery selector, default: $.mobile.pageContainer) specifies the container that should contain the page.
reloadPage (boolean, default: false)
Force refresh of the page, even when the DOM element in the page container is ready. Only available when the to parameter of changePage() is an address.
reverse (boolean, default: false)
Set the direction of the page transition animation. When set to true, it will cause the transition in the opposite direction.
role (string, default: undefined)
Use the data-role value when displaying the page. By default this parameter is undefined, meaning it depends on the element's @data-role attribute.
showLoadMsg (Boolean value, default: true) Set whether to display loading information when loading external pages.
transition (String, default: $.mobile.defaultPageTransition) Transition when using the displayed page.
type (string, default: get)
Specify the method used when requesting the page ("get" or "post"). Only available when the to parameter of changePage() is an address.
//以slideup效果 跳转到 "about us" 页面 $.mobile.changePage("about/us.html", "slideup"); //以pop效果 跳转到 "confirm" 页面 并且在url hash里不记录其历史 $.mobile.changePage("../alerts/confirm.html", "pop", false, false); //跳转到 "search results" 页面,提交id为 "search"的表单数据 $.mobile.changePage({url:"searchresults.php" , type:"get" , data: $("form#search").serialize() }); //将页面url,类型,数据定义为变量来传递。 var pageData = { url: formresults.php, type: 'get', data:$('form#myform').serialize () }; $.mobile.changePage(pageData); //使用changepage来加载第三个页面 var previousPage = $.mobile.activePage.data ('ui.prevPage'); $.mobile.changePage([previousPage, anotherPreviousPage], 'pop');
loadPage() loads external page
jQuery.mobile.loadPage( url [, options ] )
加载一个外部页面,附加其内容,并将其插入到DOM
url:是第一个参数。是必须的。类型:字符串或者对象。
options:第二个参数。是可选的。类型:对象。
allowSamePageTransition (default: false)
类型:布尔值
默认情况下,changepage()忽略请求改变当前页面。这个选项设置为true,允许请求执行。开发人员应该注意的一些网页过渡假设一个changepage请求设置FromPage、ToPage是不同的,所以他们可能不会如预期的动画。开发人员负责提供适当的过渡,或关闭这个特定的情况下。
changeHash (default: true)
类型:布尔值
如果地址栏中的哈希值应更新
data (default: undefined)
类型:数据或者字符串
要发送的数据与一个AJAX页面请求
loadMsgDelay (default: 50)
类型:数字
被迫延迟(毫秒)显示之前加载信息。这是为了让一个页面已经访问了被从缓存中取得没有加载信息的时间
pageContainer (default: $.mobile.pageContainer)
类型:jQuery选择器
指定要包含的页面元素
reloadPage (default: false)
类型:布尔值
强制刷新页面, 即使当页面容器中的dom元素已经准备好时,也强制刷新。只在changePage() 的 to 参数 是一个地址的时候可用。
role (default: undefined)
类型:字符串
显示页面的时候使用data-role值。默认情况下此参数为认:undefined,依赖于元素的@data-role属性。
showLoadMsg (default: true)
类型:布尔值
加载外部页面时,设定是否显示loading信息。
transition (default: $.mobile.defaultPageTransition)
类型:字符串
使用显示的页面时,过渡
type (default: "get")
类型:字符串
指定页面请求的时候使用的方法("get" 或者 "post")。只在changePage() 的 to 参数 是一个地址的时候可用。
加载一个外部页面,提高其内容,并将其插入到DOM。这种方法被称为内部的changepage()功能时,它的第一个参数是一个URL。这个函数不影响当前页面可以在后台加载页面。该函数返回一个对象,获取延期承诺在该页被增强,插入到文档中的解决。
加载“about/us.html”的页面到DOM
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>jQuery.mobile.loadPage demo</title> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css"> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <!-- The script below can be omitted --> <script src="/resources/turnOffPushState.js"></script> <script src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script> </head> <body> <div data-role="page"> <div></div> </div> <script> $.mobile.loadPage( "about/us.html" ); </script> </body> </html>
加载一个“searchresults.php”页,要发送的表单数据是“search”字符。
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>jQuery.mobile.loadPage demo</title> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css"> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <!-- The script below can be omitted --> <script src="/resources/turnOffPushState.js"></script> <script src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script> </head> <body> <div data-role="page"> <div></div> </div> <script> $.mobile.loadPage( "searchresults.php", { type: "post", data: $( "form#search" ).serialize() }); </script> </body> </html>

JavaScript's application in the real world includes front-end and back-end development. 1) Display front-end applications by building a TODO list application, involving DOM operations and event processing. 2) Build RESTfulAPI through Node.js and Express to demonstrate back-end applications.

The main uses of JavaScript in web development include client interaction, form verification and asynchronous communication. 1) Dynamic content update and user interaction through DOM operations; 2) Client verification is carried out before the user submits data to improve the user experience; 3) Refreshless communication with the server is achieved through AJAX technology.

Understanding how JavaScript engine works internally is important to developers because it helps write more efficient code and understand performance bottlenecks and optimization strategies. 1) The engine's workflow includes three stages: parsing, compiling and execution; 2) During the execution process, the engine will perform dynamic optimization, such as inline cache and hidden classes; 3) Best practices include avoiding global variables, optimizing loops, using const and lets, and avoiding excessive use of closures.

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.

The shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.

Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.

JavaScript's applications in the real world include server-side programming, mobile application development and Internet of Things control: 1. Server-side programming is realized through Node.js, suitable for high concurrent request processing. 2. Mobile application development is carried out through ReactNative and supports cross-platform deployment. 3. Used for IoT device control through Johnny-Five library, suitable for hardware interaction.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version
Useful JavaScript development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.