Changing iFrame Source
Using JQuery to change iframe source. RESPONSIVE
by dshilkret
HTML
<script>
var current_url = location.href;
var current_page = "";
alert(current_url.indexOf('?'));
if (current_url.indexOf('?')> 0) {
current_page = current_url.slice(current_url.indexOf('display/')+7,current_url.indexOf('?'));
alert("currentPage" + current_page);
} else {
current_page = current_url.split('editor_console').pop();
}
$("[name='CurrentPage']").attr('src', current_page );
//window.top.location.href =document.referrer.substr(0, document.referrer.indexOf('Travel/')) + 'NextPage';
</script>
<p><a href="http://applications.3d4medical.com" target="someFrame">Charlie 1</a></p>
<p><a href="http://www.3d4medical.com" target="someFrame">Charlie 2</a></p>
<p><a href="http://uidesignbits.com" target="someFrame">Charlie 3</a></p>
<div class="iframeContainer">
<iframe name="someFrame" id="someFrame" src="http://www.3d4medical.com" frameborder="0" scrolling="no">
Your browser doesn't support iframes.
</iframe>
</div>
CSS
html, body { height:100%; }
.iframeContainer {
width:90%;
height:100%;
overflow:hidden;
}
#someFrame {
width:100%;
height:100%;
}
JavaScript
$(document).ready(function(){
$("a").click(function(e) {
//alert(location.href);
e.preventDefault();
$("#someFrame").attr("src", $(this).attr("href"));
getLocation();
})
});
function getLocation(){
console.log(location.href);
console.log(document.referrer);
}