inline javascript inside head section

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

inline javascript inside head section

Gerhard Obermann
I want to create a javascript inside the head section
without doing a callback.
 
I tried the following code:
 anHtmlRoot javascript add: 'function test() {.....}'
 
The problem is, that in this case the javascript will be also encoded and this
breaks my javascript code.
 
The only solution i found up to now, is to override the encodeOn: method in WAScriptElement
 
encodeOn: aDocument
 aDocument openTag: self tag attributes: attributes closed: self isClosed.
 self isClosed ifTrue: [ ^ self ].
 self childrenDo: [ :each | aDocument nextPutAll: each].
 aDocument closeTag: self tag
 
btw: i am using seaside 2.9
 
cheers Gerhard
 
 

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: inline javascript inside head section

Philippe Marschall
2008/1/26, Gerhard Obermann <[hidden email]>:
> I want to create a javascript inside the head section
> without doing a callback.
>
> I tried the following code:
>  anHtmlRoot javascript add: 'function test() {.....}'

Right, we need the same hacks that we currently have for <script> in
the body in the head as well.

Issue created:
http://bugs.squeak.org/view.php?id=6875

Seaside-Tests-pmm.21 has a test for this bug:

WAHtmlRootTest >> #testJavascript
        self
                assert: [ :html |
                        html javascript
                                add: 'true & false'  ]
                gives: '<title></title><script
type="text/javascript">/*<![CDATA[*/true & false/*]]>*/</script>'


> The problem is, that in this case the javascript will be also encoded and
> this
> breaks my javascript code.
>
> The only solution i found up to now, is to override the encodeOn: method in
> WAScriptElement
>
> encodeOn: aDocument
>  aDocument openTag: self tag attributes: attributes closed: self isClosed.
>  self isClosed ifTrue: [ ^ self ].
>  self childrenDo: [ :each | aDocument nextPutAll: each].
>  aDocument closeTag: self tag

If this functionality is critical for you and you can't put the script
in an external file then this quick hack should work. Note however
that your page is unlikely to validate against XHTML. You can change
your doctype to HTML if validation is important to you.

> btw: i am using seaside 2.9

Wow.

Cheers
Philippe

> cheers Gerhard
>
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: inline javascript inside head section

Philippe Marschall
Fixed in Seaside-Core-lr.44. Geez that was fast, thanks Lukas.

Cheers
Philippe

2008/1/26, Philippe Marschall <[hidden email]>:

> 2008/1/26, Gerhard Obermann <[hidden email]>:
> > I want to create a javascript inside the head section
> > without doing a callback.
> >
> > I tried the following code:
> >  anHtmlRoot javascript add: 'function test() {.....}'
>
> Right, we need the same hacks that we currently have for <script> in
> the body in the head as well.
>
> Issue created:
> http://bugs.squeak.org/view.php?id=6875
>
> Seaside-Tests-pmm.21 has a test for this bug:
>
> WAHtmlRootTest >> #testJavascript
>         self
>                 assert: [ :html |
>                         html javascript
>                                 add: 'true & false'  ]
>                 gives: '<title></title><script
> type="text/javascript">/*<![CDATA[*/true & false/*]]>*/</script>'
>
>
> > The problem is, that in this case the javascript will be also encoded and
> > this
> > breaks my javascript code.
> >
> > The only solution i found up to now, is to override the encodeOn: method in
> > WAScriptElement
> >
> > encodeOn: aDocument
> >  aDocument openTag: self tag attributes: attributes closed: self isClosed.
> >  self isClosed ifTrue: [ ^ self ].
> >  self childrenDo: [ :each | aDocument nextPutAll: each].
> >  aDocument closeTag: self tag
>
> If this functionality is critical for you and you can't put the script
> in an external file then this quick hack should work. Note however
> that your page is unlikely to validate against XHTML. You can change
> your doctype to HTML if validation is important to you.
>
> > btw: i am using seaside 2.9
>
> Wow.
>
> Cheers
> Philippe
>
> > cheers Gerhard
> >
> >
> > _______________________________________________
> > seaside mailing list
> > [hidden email]
> > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> >
> >
>
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside