Re: [PHP] innerHTML triple quotes issue
On Thu, Sep 15, 2011 at 5:01 AM, Grega Leskovšek wrote: > > My Heavenly profession is being onmouseover=' src=\"http://imagecache2.allposters.com/images/PF_New/102008/3070943.jpg\"; > alt =\"close to my heavenly face\" />'";?>' > onmouseout="this.innerHTML='an angel'">an angel, > > > I first tried this but got a mistake and then I tried to use php to > settle this look above, but got parsing mistake. > It's easy to forget that, although you are embedding JavaScript in the onmouseover and onmouseout attributes of the element, the content of those attributes is still technically HTML, so the single and double quotes as well as the tag angle brackets inside the attribute should probably be the HTML entities (" ' < and >) instead of the literal characters. This avoids the issue with nesting and escaping quotes across three languages (PHP -> HTML -> Javascript). Of course, when testing this, my first attempt worked in Firefox, Opera, Safari and Chrome but failed in IE (version 8). (Go figure) http://imagecache2.allposters.com/images/PF_New/102008/3070943.jpg"; />'" onmouseout="this.innerHTML='an angel'" > an angel So then I tried a mixed approach and it seems to work in all of them: http://imagecache2.allposters.com/images/PF_New/102008/3070943.jpg"; />'" onmouseout="this.innerHTML='an angel'" > an angel YMMV Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] innerHTML triple quotes issue
Grega, Do you HAVE TO use PHP to echo the output or can you just write it in HTML? It seems much simpler and if so... below will work. The code is not indented properly but I did this so you can see what's going on. HTML VERSION My Heavenly profession is being http://imagecache2.allposters.com/images/PF_New/102008/3070943.jpg\' />'" onmouseout="this.innerHTML='an angel'" > an angel Hope that helps, cheers! Jen -Original Message- From: Grega Leskovšek [mailto:legr...@gmail.com] Sent: Thursday, September 15, 2011 4:01 AM To: php-general Subject: [PHP] innerHTML triple quotes issue My Heavenly profession is being http://imagecache2.allposters.com/images/PF_New/102008/3070943.jpg\"; alt =\"close to my heavenly face\" />'";?>' onmouseout="this.innerHTML='an angel'">an angel, I first tried this but got a mistake and then I tried to use php to settle this look above, but got parsing mistake. although not fully liberated I came to work in this world for http://t1.gstatic.com/images?q=tbn:ANd9GcTaxIC0HvMMWTlZ2ozXMcwTsqRcStUXRWItISeVyDrVkzVtv2s-AVmn6v3x\"; alt =\"Lord Krishna in His garden of flowers, that's a spiritual world\" />'" onmouseout="this.innerHTML='Lord Krishna\'s Realisation.'">Lord Krishna's Realisation. Could YOu please look a t my code and exlpain me what to do if I need to use triple quotoes - we only have " and ' in onmouseover 1, thisINNERHTML 2 and in src 3 Please help me! ♥♥♥ When the sun rises I receive and when it sets I forgive! ♥♥♥ ˜♥ -> http://moj.skavt.net/gleskovs/ <- ♥ Always, Grega Leskovšek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php