Hi!
I have an <iframe>
control on my page and I want to change it's target url (the url of the page displayed in the iframe) by a click on a hyperlink. The problem is that the iframe doesn't update on the click. I'm pretty sure I'm missing something, but I don't know what:
<script type="text/javascript">
var source = document.getElementById("CurrentlySelected")
function change(u) {
if (source.getAttribute("src") != u) {
source.setAttribute("src", u);
document.location.reload(true);
}
}
</script>
<ul>
<li><a href="#" onclick="change('http://www.somewebsite.com');">Website 1</a></li>
<li><a href="#" onclick="change('http://www.thiswebsite.net');">Website 2</a></li>
</ul>
<iframe id="CurrentlySelected" width="800px" height="600px" src="http://www.somewebsite.com"></iframe>
JS is not my forte, but I don't see a problem here... any ideas?
Another problem is that the background of the iframe isn't taking the same color of the website linked in its src attribute...
EDIT
The issue with the background color of the website in the iframe seems to be an issue with Google Chrome, anyone know about a fix?