Skip to content

Instantly share code, notes, and snippets.

@tamewhale
Created November 30, 2011 16:03
Show Gist options
  • Save tamewhale/1409611 to your computer and use it in GitHub Desktop.
Save tamewhale/1409611 to your computer and use it in GitHub Desktop.
Changing the data attribute of an object
<div id="scrollee" style="height:75%;" >
<object id="object" height="90%" width="100%" type="text/html" data="http://en.wikipedia.org/"></object>
</div>
<a id="change-link" href="http://yahoo.com">link</a>
<script type="text/javascript">
window.onload = function() {
var el = document.getElementById("change-link");
el.onclick = function() {
var target = this.getAttribute("href");
var el = document.getElementById("object");
el.setAttribute("data", target);
return false;
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment