Embedded video without rendering in Chrome on first load after embedding code is saved in the Rails model

We have a Ruby on Rail application that allows the user to save several embed video codes into our data model. The form allows the user to enter any number of insert codes, click the "Submit" button and save everything in the database. Then the application redirects the user to a page with a list of all embedded codes.

This workflow works great for IE, Safari, and Firefox.

In Chrome, however, the first time a page loads, none of the videos appear on the page. I see the following error in the console: once for each video:

Refused to execute JavaScript script. The source code for the script was found in the request.

The next time the page loads, the video loads in order and this error does not appear.

When I browse the source, the page reloads for the operation of the view source, so I can’t determine if the source passes as expected.

When I check an element on the block where the video should be, I see the following:

<iframe src="" width="400" height="225" frameborder="0">
  <html>
    <head></head>
    <body></body>
  </html>
</iframe>

This happens for both iframe style codecs and the "old style" tag code for YoutTube and Vimeo videos.

on this topic:

+5
source share
2 answers

How Chrome Prevents XSS (Cross-Site Scripting) as your link above.

, , Chrome , ( HTTP POST)), , .

, HTTP POST ( ), .

, .

+6

iframes javascript ( jquery) .

src , .

url src src2, src2.

iframe, 'webkitIframeHack'.

<script type="text/javascript">
$(function(){
    if ($.browser.webkit) {
        $("iframe.webkitIframeHack").each(function(){
            $(this).attr('src', $(this).attr('src2'));
        });
    };
});
</script>

( html5 data- *, , ..)

+1

All Articles