how to update iframe src from viewmodel

559 views
Skip to first unread message

Patrick Beagan

unread,
Nov 13, 2013, 12:35:48 AM11/13/13
to knock...@googlegroups.com
I'm trying to update an iframe from knockout and having difficulties getting it to work.  I can successfully give the iframe an initial src value,  but  I can't  subsequently update it from a function.  here is the fiddle: http://jsfiddle.net/patrickb323/LXYSM/25/

I'm a newbie to JavaScript/knockout.  thanks for the help!

Patrick Steele

unread,
Nov 13, 2013, 7:27:57 AM11/13/13
to knock...@googlegroups.com
This is not a knockout issue but a security issue.

Google.com uses the x-frame-options HTTP response header to limit who can "frame" their pages (and Google sets the value to SAMEORIGIN meaning only Google.com can iFrame its pages):


If you use Chrome and open up Chrome's developer tools (F12), look at the Console tab when running your fiddle.  it displays an error message when your viewmodel tries to update the src:

Refused to display 'https://www.google.com/' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

So, your code works fine, but security reasons prevent you from using google.com as your iframe source.

On Wed, Nov 13, 2013 at 12:35 AM, Patrick Beagan <pbe...@gmail.com> wrote:
I'm trying to update an iframe from knockout and having difficulties getting it to work.  I can successfully give the iframe an initial src value,  but  I can't  subsequently update it from a function.  here is the fiddle: http://jsfiddle.net/patrickb323/LXYSM/25/

I'm a newbie to JavaScript/knockout.  thanks for the help!

--
You received this message because you are subscribed to the Google Groups "KnockoutJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to knockoutjs+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages