我是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>
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');
如果我了解您的意思是正确的,则可能要使用<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>