views:

24

answers:

1

In the options page of my Google chrome extension, the user defines a URL destination which saves to LocalStorage["dest"]

Can't get the code to work in the popup.html file though

<script type="text/javascript">
  url = localStorage["dest"]; 
  document.getElementById('site').src = url;
</script>

<iframe id="site"> </iframe>

What am I doing wrong? Basically I want the popup to load whatever site the user saves in the options page, in an Iframe...

+2  A: 

The script tag is before the iframe tag. When you do document.getElementById('site') the iframe does not exist yet. You need to move the iframe tage before the script tag. In general, it's best to put all your scripts right before the closing body tag.

jcmoney
Thanks mate, I hate it when its something so trivial...:)
David