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
WBOYOriginal
2016-05-16 16:38:081476browse

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 35a7a2479e4663ba6cfbedf9c115a3a2950c0e09a208ea6a6c67c615a801fbc6

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

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);
})

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

Statement:
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