1

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!

Ram
  • 143,282
  • 16
  • 168
  • 197
luaLover
  • 141
  • 1
  • 11
  • You can't directly insert google, facebook or youtube in an iframe because of the [SameOrigin Policy](http://stackoverflow.com/questions/8700636/how-to-show-google-com-in-an-iframe). – blex May 21 '14 at 23:34
  • Yes you're right, even all google websites (Youtube included) and Facebook as well doesn't work if they are in a frame, but mine was just an example, I could have typed one.html, two.html and three.html. – luaLover May 22 '14 at 06:23

1 Answers1

1

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.

eric.christensen
  • 3,191
  • 4
  • 29
  • 35