Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigate URL in iframe with Javascript

I have this code, to navigate a URL with javascript in an iframe, but it does not work. Why?

For example, I want navigate to site.com when I click link1.

<script language="javascript">
function nav()
{
window.navigate('http://site.com',target="DBox");
}   
</script>   


<a href="javascript:nav();">link1</a>

<iframe name="DBox" src="http://example" frameborder="0" style="width:100%;height:100%"></iframe> 
like image 241
User Avatar asked Jan 02 '12 14:01

User


1 Answers

Simple HTML:

<a target="DBox" href="http://site.com">link1</a>

Or with just call this with JavaScript:

window.open("http://site.com", "DBox");
like image 143
noob Avatar answered Sep 29 '22 19:09

noob