Re: [PHP] innerHTML triple quotes issue

2011-09-15 Thread Jen Rasmussen
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
h3My Heavenly profession is being/h3
span class=see 
onmouseover=this.innerHTML='img 
src=\'http://imagecache2.allposters.com/images/PF_New/102008/3070943.jpg\' /' 
onmouseout=this.innerHTML='an angel'

an angel/span

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

h3My Heavenly profession is being span class=see
onmouseover='?php echo this.innerHTML=' img
src=\http://imagecache2.allposters.com/images/PF_New/102008/3070943.jpg\;
alt =\close to my heavenly face\ /';?'
onmouseout=this.innerHTML='an angel'an angel/span,


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 span class=see
onmouseover=this.innerHTML='img
src=\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./span/h3


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



Re: [PHP] innerHTML triple quotes issue

2011-09-15 Thread Andrew Ballard
On Thu, Sep 15, 2011 at 5:01 AM, Grega Leskovšek legr...@gmail.com wrote:

 h3My Heavenly profession is being span class=see
 onmouseover='?php echo this.innerHTML=' img
 src=\http://imagecache2.allposters.com/images/PF_New/102008/3070943.jpg\;
 alt =\close to my heavenly face\ /';?'
 onmouseout=this.innerHTML='an angel'an angel/span,


 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 (quot; apos; lt; and gt;) 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)

span class=see
onmouseover=this.innerHTML=apos;lt;brgt;lt;img
src=quot;http://imagecache2.allposters.com/images/PF_New/102008/3070943.jpgquot;
/apos;
onmouseout=this.innerHTML=apos;an angelapos;

an angel/span



So then I tried a mixed approach and it seems to work in all of them:

span class=see
onmouseover=this.innerHTML='lt;brgt;lt;img
src=quot;http://imagecache2.allposters.com/images/PF_New/102008/3070943.jpgquot;
/'
onmouseout=this.innerHTML='an angel'

an angel/span


YMMV

Andrew

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php