Home  >  Article  >  Web Front-end  >  jQuery implements the function of jumping between browsers and passing parameters [supports Chinese characters]

jQuery implements the function of jumping between browsers and passing parameters [supports Chinese characters]

亚连
亚连Original
2018-05-28 16:15:341714browse

This article mainly introduces jQuery's function of jumping between browsers and passing parameters. It has the function of supporting Chinese character transmission and involves jQuery encoding conversion, event response, page jump and other related operation skills. Friends who need it can Refer to the following

The example of this article describes the jQuery function of jumping between browsers and passing parameters. Share it with everyone for your reference, the details are as follows:

one.html

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title></title>
  <script src="https://cdn.bootcss.com/jquery/2.2.2/jquery.slim.js"></script>
</head>
<body>
<input type="text" class="keyword"/>
<button id="searchBtn">点击</button>
<script type="text/javascript">
  $("#searchBtn").click(function() {
    var searchText = jQuery.trim($(".keyword").val());
    var searchUrl = encodeURI("two.html?searchText=" + searchText); //使用encodeURI编码
    location.href = searchUrl;
  })
</script>
</body>
</html>

two.html

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title></title>
  <script src="https://cdn.bootcss.com/jquery/2.2.2/jquery.slim.js"></script>
</head>
<body>
<input type="text" class="keyword1"/>
<script type="text/javascript">
  //获取 上一个搜索页面传来的参数 
  var searchUrl = window.location.href;
  var searchData = searchUrl.split("="); //截取 url中的“=”,获得“=”后面的参数
  var searchText = decodeURI(searchData[1]); //decodeURI解码
  $(".keyword1").val(searchText);
</script>
</body>
</html>

Run results:

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

Ajax image upload based on firefox

Ajax loading external page pop-up layer effect implementation method

Ajax cross-domain (same basic domain name) form submission method

The above is the detailed content of jQuery implements the function of jumping between browsers and passing parameters [supports Chinese characters]. For more information, please follow other related articles on the PHP Chinese website!

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