Javascript document.write ('HTML CODE HERE') and using var captured by flash

so these are 2 questions in one. My first question is: how do I do this?

    document.write('
<div id="jwplayer">
<center>
<div id='mediaplayer'></div>
<script type="text/javascript">
  jwplayer('mediaplayer').setup({
    'flashplayer': 'jwplayer/player.swf',
    'id': 'playerID',
    'width': '640',
    'height': '580',
    'provider': 'rtmp',
    'streamer': 'rtmp://domain/recorder/_definst_',
'file': 'onSaveOk("+streamName+")'
  });
</script>
</center>
</div>
');

I just want to print this code when calling a function.

This is the second part of my question, this function works when the VCR finishes saving the recorded video. It captures all the variables in the function arguments from the flash player. I want to use one of the variables in my jwplayer code, how would I do it?

Here is the function:

    function onSaveOk(streamName,streamDuration,userId,cameraName,micName,recorderId){
        //alert("onSaveOk("+streamName+","+streamDuration+","+userId+","+cameraName+","+micName+")");

        //the user pressed the [save] button inside the recorder and the save_video_to_db.XXX script returned save=ok
        //recorderId: the recorderId sent via flash vars, to be used when there are many recorders on the same web page
            $('#record').hide();
    document.write('
<div id="jwplayer">
<center>
<div id='mediaplayer'></div>
<script type="text/javascript">
  jwplayer('mediaplayer').setup({
    'flashplayer': 'jwplayer/player.swf',
    'id': 'playerID',
    'width': '640',
    'height': '580',
    'provider': 'rtmp',
    'streamer': 'rtmp://domain/recorder/_definst_',
'file': 'onSaveOk("+streamName+")'
  });
</script>
</center>
</div>
');


    }

Here I am trying to use the streamName function, but it does not work:

'file': 'onSaveOk("+streamName+")'

How can I do it? Thanks.

+2
source share
2 answers

-, JavaScript , --bat document.write . . , ...

var lines = '<div id="jwplayer"><center>...</center></div>';
document.write(lines);

... . ...

var lines = '<div id="jwplayer">\
    <center>\
      ...\
    </center>\
  </div>';
document.write(lines);

... , , , - , , . ...

var lines = '<div id="jwplayer">';
lines += '<center>';
lines += '...';
lines += '</center>';
lines += '</div>';
document.write(lines);

..., , , . , ...

var lines = [
  '<div id="jwplayer">',
  '<center>',
  '...',
  '</center>',
  '</div>'].join(' ');
document.write(lines);

... [ ] lines += .... , , , .

, , , - . , , , :

var lines = "<div id=\"jwplayer\">";
lines += '<div id=\'mediaplayer\'></div>';

, (?) , html, , , . , .

, , - , , streamName, , , , . ,

lines += "'file': 'onSaveOk(" + streamName + ")'";

, .

: a) document.write() b) <center>, , ; , 1998 : " , , ".

+5

, :

// html

var html = ''+
    '<body>'+
        '<div>'+
            '<a href="foo.bar">Foo Bar page</a>'+
        '</div>'+
    '</body>';

javascript 'foo' +\n\r\t'bar '==' foobar ';

+2

Source: https://habr.com/ru/post/1613611/


All Articles