5
It is said that Document.write is not a good practice, and it also doesn’t work after window.onload, which is the case I need. I have the following function that needs to change Document.write, the detail is that I need the content to be added in the same tag/element that is the call of the function inside the tag , without the parent element always being the same.
function GerarSWF($arquivo,$largura,$altura,$id){
document.writeln(' <object type="application/x-shockwave-flash" id="' + $id + '" data="' + $arquivo + '" width="' + $largura + '" height="' + $altura + '">');
document.writeln(' <param name="movie" value="' + $arquivo + '" />');
document.writeln(' <param name="menu" value="false" />');
document.writeln(' <param name="wmode" value="transparent" />');
document.writeln(' <embed src="' + $arquivo + '" type="application/x-shockwave-flash" wmode="transparent" menu="false" quality="high" id="' + $id + '" width="' + $largura + '" height="' + $altura + '"></embed>');
document.writeln(' </object>');
}
example of the situation:
<html>
<body>
<div id="pode_nem_sempre_ser_o_mesmo">
<div>
<script>GerarSWF(bla,bla);
//o conteudo tem q ficar dentro dessa div q está o <script>
//mas pode aparecer em locais diversos, nem sempre saberei o id ou tag
</script>
</div>
</div>
</body>
Can you do that? thanks in advance for the attention
Have you tried the
innerHTML
?– Edilson
You can put an id in the div?
– bfavaretto
Although in this particular case
document.write
should work.– bfavaretto
@Edison, I don’t know how to do this without specifying the id, it’s like?
– SuperMax
@bfavaretto, the call comes from inside articles and already mtos, would not have to change that. So, there is no way to change and put an id, sometimes even has , but as said is not always the same
– SuperMax
You can identify the block
<script>
that’s spinning, but that doesn’t always work.– bfavaretto
Where does this? server code come from? PHP? why not generate HTML already with everything, instead of doing Javascript that will write HTML? Explain a little better where the code comes from.
– Sergio
the function is inside a.js file loaded with async tag. This function is already inside hundreds of articles in a database. Therefore changing each one is not a viable alternative method as I changed the loading of the.js file a little while ago, I’m having to make some adjustments and this is the last one. In case I have to rename the function inside the.js file to Gerarsfw2 and in the page I have to create the Function Gerarsfw(){window.load=Gerarsfw2();} . This pq qdo the.js file is loaded async, no way to know when it will be completed and it may occur after the function is called, the error qdaria
– SuperMax
Can you show the php function that generates this example HTML? how
GerarSWF($arquivo,$largura,$altura,$id)
receives these arguments?– Sergio
is in Asp, but there is no programming in relevant Asp in this section. is a content in a data database field that contains an article basically with text and html, in case someone uses image or flash by the content editor, the editor inserts this code, I could change it but would only change the new ones and would have a hell of a job to change the old ones that are already there
– SuperMax