Learn free online HTML5, javascript, and jquery Tutorials by Examples

Saturday 17 May 2014

How to open link into iframe using javascript

--------------------------------------------------
<div id="links">
  <a href="http://stuff.com" onclick="return go(this);">stuff</a>
  <a href="http://www.fun.com" onclick="return go(this);">fun</a>
  <a href="http://bing.com" onclick="return go(this);">bing</a>
</div>

<div id="container"></div>
<style>
div#container {
    width:500px;
    height:500px;
    overflow:hidden;
}
</style>

<script>
function go(obj) {
    var page=obj.href;
    document.getElementById('
container').innerHTML='<object data="'+page+
      '" type="text/html"><embed src="'+page+'" type="text/html" /></object>';
    return false;
}
</script>
-------------------------------------------------- 

No comments:

Post a Comment