Home > Web Front-end > JS Tutorial > Use js to pass parameters through url to transfer data from one page to another_javascript skills

Use js to pass parameters through url to transfer data from one page to another_javascript skills

WBOY
Release: 2016-05-16 16:38:08
Original
1477 people have browsed it

Use js to transfer data from one page to the layer of another page?

If it is transferred to a new page, directly use get or post to obtain the language in which your website is developed, and then output it to this layer

Transfer parameters via url

If it is an HTML page, the JS passed to the new page will be window.location.href='a.html?id=100'; and then the JS of the a.html page will be

< /div>

<script>
document.getElementById("s").innerHTML=window.location.split('&#63;')[1];
</script>
Copy after login

If you want to implement AJAX to transfer parameters from page a to page b and display the results of executing parameters of page b on the layer of page a, then use AJAX

This is too much to write, so I’ll give you JQUERY

<div id="a"></div>
$("#a").load("b.html&#63;id=100");
//或者
$.get("b.html&#63;id=100",function(data){
$("#a").html(data);
})
Copy after login

There are also POST methods, so I won’t list them all here

Related labels:
url
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template