You can put the <script> block pretty much anywhere since it does not execute until the document has finished loading, at which time it will insert your specified script immediately after the element with id='myElem'.
Presumably your script is suitable for insertion into a loaded document.
Phil & Philip: I think you are misdiagnosing his problem.
That script he is invoking is used to document.write code to embed a Flash object in the page.
Well I did warn about that possibility, but now I know there's only one thing for it.
1) Remove the code I gave you.
2) Place your original <script> tags for the clock at the end of the <body> section, then immediately below those tags (still inside the body) add this script block:
Code:
<script type='text/javascript'>
(function()
{
var objs = document.getElementsByTagName('object'),
me = document.getElementById( 'myElem' );
for( var i = 0, found = false, clsId; i < objs.length && !found; i++ )
{
clsId = objs[i].getAttribute('classid') || "";
if( clsId === "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" )
{
found = true;
me.parentNode.insertBefore( objs[i], me.nextSibling );
}
}
})();
</script>
3) Make sure this element has the ID as shown here: <h2 id='myElem'>Welcome Tony Website</h2>
Users who have thanked RandomUser531 for this post:
ok, finaly the script is working, BUT it is working fine only on Internet Explorer, but not on Firefox, on Firefox the clock is Hovering above the text that is supposed to be after it, and not under it? So what is the solution?
ok, finaly the script is working, BUT it is working fine only on Internet Explorer, but not on Firefox, on Firefox the clock is Hovering above the text that is supposed to be after it, and not under it? So what is the solution?
That will just be a page-layout issue. Try adding a <p> or <br> tag after your <h2> and transfer id='myElem' to that tag. Whatever you do, remember that the clock will be inserted immediately after whichever element has id='myElem'.
Users who have thanked RandomUser531 for this post:
Ok, the script is working, thanks.
I had those last 2 questions:
1- If I put the srcipt (that You showed Me above)
Code:
<script type='text/javascript'>
(function()
{
var objs = document.getElementsByTagName('object'),
me = document.getElementById( 'myElem' );
for( var i = 0, found = false, clsId; i < objs.length && !found; i++ )
{
clsId = objs[i].getAttribute('classid') || "";
if( clsId === "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" )
{
found = true;
me.parentNode.insertBefore( objs[i], me.nextSibling );
}
}
})();
</script>
does it make all the JavaScript scripts in My page to load after the loading time?
(for example I had a second clock but the script of the other clock isn't directly over the script that You showed Me, so does this other clock load after the page loads, or it will load normally with the page according to it's position)
2- If I put a Javascript code that shows that the page is loading "Please Wait", does the clock code (that We discussed in the posts above), will be loaded before or after the loading message (please wait) disappears?