Search code examples
phpjavascriptprototypejsscriptaculous

Scriptaculous highlight effect on php print


I want this effect when php print gets called . How can i do it?

I have tried with

print "<span id=\"highlight\" onLoad=\"Effect.Highlight(highlight);\"><em>Your post was successfully added.</em></span>"."<hr>";

but this is not working. Help!


Solution

  • if it does not need to be in the php itself then use (advise against using short tags to open and close):

    ?>
    <span id="highlight" onLoad="Effect.Highlight(this.id);"><em>Your post was successfully added.</em></span><hr>
    <?php 
    

    and continue your script.

    alternatively,

    <head>
    ...
    object.onload="SomeJavaScriptCode";
    ...
    </head>
    

    --EDIT--

    Javascript would look like:

    <script type="javascript/text">
    body.onload=Effect.Highlight(getElemenyById('highlight'));
    </script>
    

    -- EDIT --

    Javascript, I believe, (thanks to comments) will look like:

    document.addEventListener('DOMContentLoaded', function () {
    Effect.Highlight(getElemenyById('highlight'));
    }, false);