如何将数据从一个html页面传输到另一html页面

问题描述 投票:0回答:2

我是HTML和javascript的新手。所以基本上我有2个HTML文件

a.html

<html>
    <head>
    <!-- Some Stuff-->
    </head>
    <body>

    <script>
    </script>
    <!--In this part there is going to be a url of pdf. 
        I want that URL to be transferred to b.html 
        so that the same pdf could be shown.-->
    </body>
</html>

b.html

<html>
<!-- Code goes here-->
</html>
javascript html
2个回答
0
投票
function getParameterByName(name, url) {
    if (!url) url = window.location.href;
  name = name.replace(/[\[\]]/g, '\\$&');
  var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
    results = regex.exec(url);
  if (!results) return null;
  if (!results[2]) return '';
  return decodeURIComponent(results[2].replace(/\+/g, ' '));
}



 var foo = getParameterByName('foo'); 
 var bar = getParameterByName('bar'); 
  var qux = getParameterByName('qux'); 

0
投票

如果我了解您的意思是正确的,则可能要使用<iframe>标签。在此标记内,您可以为src属性设置网址:

<iframe src="https://mozilla.github.io/pdf.js/web/viewer.html"></iframe>

iframe {
  width: 500px;
  height: 200px;
}
<iframe src="https://mozilla.github.io/pdf.js/web/viewer.html"></iframe>
© www.soinside.com 2019 - 2024. All rights reserved.