Reputation: 21
We have embedded tutorial youtube videos for new members of a forum, and would like to incorporate an iFrame which loads the referring forum page on our tutorial page, when they click a help video link. This would allow members to pause the video, and actually try out the instructions on the forum page they were on, without having to either tab back and forth, or having two browser windows open. We tried using popup videos, but didn't work well for our purposes.
Is there a way to load a referring page in an iFrame such as:
<iframe src="document.referrer" style="width: 640px; height: 480px" name="forumvids"></iframe>
Nothing has worked so far. We end up just getting a blank iFrame window. Any ideas?
Thanks.
Upvotes: 2
Views: 6183
Reputation: 900
I would use :
<script>
document.write(parent.document.referrer);
</script>
Beny
Upvotes: 1
Reputation: 45745
Converting my comment to an answer (after testing it, and removing JQuery dependency)
<script>
window.onload = function(){
if(document.referrer!=null){
//alert(document.referrer); comment in for testing
document.getElementById("frame").src = document.referrer;
}
}
</script>
<iframe id="frame" />
Upvotes: 1
Reputation: 207511
src="document.referrer"
is a string there, it has no idea you are talking about JavaScript. Set it with JavaScript such as:
<iframe id="iframeId"></iframe>
<script>
var ifr = document.getElementById("iframeId");
ifr.src = document.referrer;
</script>
Just a warning, document.referrer does not always have a value.
Upvotes: 2