BlazeHtml: How to write quotation-marks in attributes?

Hi. How can I write <body onload="javascript:document.getElemByID('q').focus();"> in BlazeHtml? The problem is that single quotes are always converted to HTML. I'd appreciate a quick response. Thanks in advance. -- Morel Pisum

Hey,
The preEscapedXXX functions make sure no HTML escaping occurs. In this
case, we use preEscapedTextValue: Text, because we're passing Text to
the function, and Value, because it needs to be converted to an HTML
attribute value.
{-# LANGUAGE OverloadedStrings #-}
import Text.Blaze (Html, (!))
import qualified Text.Blaze.Html5 as H
import qualified Text.Blaze.Html5.Attributes as A
test :: Html
test = H.body ! A.onload (H.preEscapedTextValue
"javascript:document.getElemByID('q').focus();") $ ""
Hope this helps,
Cheers,
Jasper
On Wed, Apr 11, 2012 at 6:44 PM, Morel Pisum
Hi.
How can I write <body onload="javascript:document.getElemByID('q').focus();"> in BlazeHtml?
The problem is that single quotes are always converted to HTML.
I'd appreciate a quick response. Thanks in advance.
-- Morel Pisum
_______________________________________________ web-devel mailing list web-devel@haskell.org http://www.haskell.org/mailman/listinfo/web-devel

On 04/11/12 16:44, Morel Pisum wrote:
Hi.
How can I write <body onload="javascript:document.getElemByID('q').focus();"> in BlazeHtml?
The problem is that single quotes are always converted to HTML.
I'd appreciate a quick response. Thanks in advance.
While Jasper's response answered your literal question, I'd add that the reason your code isn't working isn't the HTML encoding, which should be left alone. The problem is that your event handler shouldn't have "javascript:" in front of it, and the DOM method is "getElem*ent*ById", not getElemById. Try document.getElementById('q').focus() which should come out with ', which is fine.

Hey Am 12.04.2012 00:44, schrieb Jeremy Bowers:
On 04/11/12 16:44, Morel Pisum wrote:
Hi.
How can I write <body onload="javascript:document.getElemByID('q').focus();"> in BlazeHtml?
The problem is that single quotes are always converted to HTML.
I'd appreciate a quick response. Thanks in advance.
While Jasper's response answered your literal question, I'd add that the Yes, Jasper solved my quotation-mark-issue. reason your code isn't working isn't the HTML encoding, which should be left alone. The problem is that your event handler shouldn't have "javascript:" in front of it, and the DOM method is "getElem*ent*ById", not getElemById.
Try
document.getElementById('q').focus()
which should come out with ', which is fine.
In fact, I had this problem, yes. Thank you for your help but I was able to solve this problem before. Thanks anyway. -- Keep it pure.

On Thu, Apr 12, 2012 at 2:17 AM, Morel Pisum
Hey
Am 12.04.2012 00:44, schrieb Jeremy Bowers:
On 04/11/12 16:44, Morel Pisum wrote:
Hi.
How can I write <body onload="javascript:document.getElemByID('q').focus();"> in BlazeHtml?
The problem is that single quotes are always converted to HTML.
I'd appreciate a quick response. Thanks in advance.
While Jasper's response answered your literal question, I'd add that the Yes, Jasper solved my quotation-mark-issue. reason your code isn't working isn't the HTML encoding, which should be left alone. The problem is that your event handler shouldn't have "javascript:" in front of it, and the DOM method is "getElem*ent*ById", not getElemById.
Try
document.getElementById('q').focus()
which should come out with ', which is fine.
In fact, I had this problem, yes. Thank you for your help but I was able to solve this problem before. Thanks anyway.
Also it'd be better to use the autofocus attribute of inputs. Javascript focusing is quirky and not configurable.

Am 12.04.2012 02:45, schrieb dag.odenhall@gmail.com:
On Thu, Apr 12, 2012 at 2:17 AM, Morel Pisum
wrote: Hey
Am 12.04.2012 00:44, schrieb Jeremy Bowers:
On 04/11/12 16:44, Morel Pisum wrote:
Hi.
How can I write <body onload="javascript:document.getElemByID('q').focus();"> in BlazeHtml?
The problem is that single quotes are always converted to HTML.
I'd appreciate a quick response. Thanks in advance.
While Jasper's response answered your literal question, I'd add that the Yes, Jasper solved my quotation-mark-issue. reason your code isn't working isn't the HTML encoding, which should be left alone. The problem is that your event handler shouldn't have "javascript:" in front of it, and the DOM method is "getElem*ent*ById", not getElemById.
Try
document.getElementById('q').focus()
which should come out with ', which is fine.
In fact, I had this problem, yes. Thank you for your help but I was able to solve this problem before. Thanks anyway.
Also it'd be better to use the autofocus attribute of inputs. Javascript focusing is quirky and not configurable.
Wow. That's a great advice! Thanks!
participants (4)
-
dag.odenhall@gmail.com
-
Jasper Van der Jeugt
-
Jeremy Bowers
-
Morel Pisum