Call external file by Div

1

In the script below it is possible to call an external file through this <div>

<div id="script" class="#"></div>

Look at this snippet of the script:

https://'+id+'?=

How do I get through <div>

<div id="script" class="#">
</div>  

especially the part class="#" is the area responsible for calling the '+ id +' of the script

Here's the script:

function (obj) {
    document.getElementById('script').appendChild(get_embed(obj['feed']['media']['content']));
}

var ts = Math.round((new Date()).getTime() / 1000);

var script = document.createElement('script');
script.src = 'https://'+id+'?'+(Math.round(ts/3600)).toFixed();

document.body.appendChild(script);
    
asked by anonymous 19.08.2014 / 18:05

1 answer

2

Ever try to capture the ID this way? If only <div> exists with this ID, this is the easiest way to do it.

function picasa_callback(obj) {
    document.getElementById('script').appendChild(get_embed(obj['feed']['media']['content']));
}

var ts = Math.round((new Date()).getTime() / 1000);

// Adicione ESTA linha para capturar o ID desejado:
var id = document.getElementById('script').className;

var script = document.createElement('script');
script.src = 'https:/'+id+'?'+(Math.round(ts/3600)).toFixed();

document.body.appendChild(script);
19.08.2014 / 18:38