Search code examples
javascripthtmlurlframeframeset

Change frame URL


I'm looking for a way to change a frame's URL.

Now I've got a page made up of a frameset with 2 frames: The first one is the smallest and it is a sort of "sidebar" with three links (Google, Youtube, Facebook), while the other one is the biggest and it is meant to be updated with the site chosen by the user (Who has clicked on one of the three links)

By default, the biggest frame shows google.com, so I'd like it to make it show even Youtube or Facebook, but I don't know how to update the frame's SRC.

Any suggestions?

Thanks!


Solution

  • Set the src attribute of the frame.

    document.getElementById('whatever').src = 'http://stackoverflow.com/questions/5842040/dynamically-set-frame-src-using-javascript';
    

    Of course you would replace whatever with the id of the frame you want to modify.