Inline JavaScript

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Inline JavaScript

Hank Ratzesberger
I want to include inline JavaScript in an
xhtml file the currently uses epilogue.

However, the content within <script> is not xhtml
and putting the script in comments (as below) means
it will get excluded by epilogue.

Not sure what I need to do.


<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:xforms="http://www.w3.org/2002/xforms"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xsl:version="2.0">

 <head>
 </head>
 <body>

   <script language="JavaScript" type="text/javascript">
    <!--
  var streams = new Array();
  ...
  showStreams();
    -->
 </script>

</body>
</html>

Regards,
Hank

Hank Ratzesberger
NEES Programmer
Institute for Crustal Studies
University of California, Santa Barbara




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Inline JavaScript

Alessandro  Vernet
Administrator
--- Hank Ratzesberger <[hidden email]> wrote:

> I want to include inline JavaScript in an
> xhtml file the currently uses epilogue.
>
> However, the content within <script> is not xhtml
> and putting the script in comments (as below) means
> it will get excluded by epilogue.

Hi Hank,

I think that a long time ago, some browsers did not recognize the <script>
tag, so those browsers were displaying the content <script>, which was
obviously not the desired effect. To avoid this, people were putting the
JavaScript in an HTML comment. I don't think that anyone in his right mind
would use a browser so old that it wouldn't know about the <script> tag,
so I would suggest you just remove the comment ;).

Alex

--
Blog (XML, Web apps, Open Source): http://www.orbeon.com/blog/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Inline JavaScript

Hank Ratzesberger
Alex,

Sorry to be unclear, but commenting around the
JavaScript was an attempt to eliminate an xml
processing exception:

  class org.orbeon.oxf.common.ValidationException
  MessageFatal Error: Element type "streams.length" must be followed by either attribute specifications, ">" or "/>".
  Locationoxf:/localvideo/index.xhtml
  Line116

In an xhtml file that begins like this:

  <?xml version="1.0" encoding="UTF-8"?>
  <html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:xforms="http://www.w3.org/2002/xforms"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xsl:version="2.0">

I attempted to place some JavaScript code.  I am
sure any code would have the same effect:

 <script language="JavaScript" type="text/javascript">

  var streams = new Array();
  var validFPS = new Array(0,1,2,3,4,5,6,7,8,9,10,15,20,25);
  var size = new Array();

So, the question is how/whether I can include inline javascript
in a document meant to be processed mostly by epilogue. i.e.

<page id="LocalVideo" path-info="/localvideo/"
   model="oxf:/content.xml"
   view="oxf:/localvideo/index.xhtml" />

Thank you,
Hank

----- Original Message -----
To: <[hidden email]>
Sent: Wednesday, August 10, 2005 5:49 PM
Subject: Re: [ops-users] Inline JavaScript


> --- Hank Ratzesberger <[hidden email]> wrote:
>
>> I want to include inline JavaScript in an
>> xhtml file the currently uses epilogue.
>>
>> However, the content within <script> is not xhtml
>> and putting the script in comments (as below) means
>> it will get excluded by epilogue.
>
> Hi Hank,
>
> I think that a long time ago, some browsers did not recognize the <script>
> tag, so those browsers were displaying the content <script>, which was
> obviously not the desired effect. To avoid this, people were putting the
> JavaScript in an HTML comment. I don't think that anyone in his right mind
> would use a browser so old that it wouldn't know about the <script> tag,
> so I would suggest you just remove the comment ;).
>
> Alex
>
> --
> Blog (XML, Web apps, Open Source): http://www.orbeon.com/blog/
>
>




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Inline JavaScript

Erik Bruchez
Administrator
Hank Ratzesberger wrote:

> I attempted to place some JavaScript code.  I am sure any code would
> have the same effect:

If you code is valid XML text, it will work, like the fragment below:

> <script language="JavaScript" type="text/javascript">
>
>  var streams = new Array();
>  var validFPS = new Array(0,1,2,3,4,5,6,7,8,9,10,15,20,25);
>  var size = new Array();

> So, the question is how/whether I can include inline javascript
> in a document meant to be processed mostly by epilogue. i.e.

The problem is of course that you have in your Javascript code a "<"
character at line 116, which is in XML a character indicating the
beginning of an element, hence the error.

You have two ways of fixing this:

o using an entity instead, i.e. &lt;

o surrounding your Javascript code with a CDATA section, as follows:

   <script language="JavaScript" type="text/javascript">
     <![CDATA[
       var streams = new Array();
       ... etc. ...
     ]]>
   </script>

-Erik



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Inline JavaScript

Hank Ratzesberger
Erik,

Thank you, I missed the obvious (and did
actually use CDATA a minute after I
wrote my last letter. )

One of my issues has been to provide something
accessible to staff only familiar with html.
I think we have decided that we will split
things and let them create static html pages
created under a Dreamweaver template.

(I went as far as converting html with subversive  
<div class="xsl:value-of" href="/root/somedata">
to xsl, but it's too much trouble for xforms
files.  In the long run, I hope I can put
together a real CMS.)

--Hank

----- Original Message -----
From: "Erik Bruchez" <[hidden email]>
To: <[hidden email]>
Sent: Thursday, August 11, 2005 10:15 AM
Subject: Re: [ops-users] Inline JavaScript


> Hank Ratzesberger wrote:
>
>> I attempted to place some JavaScript code.  I am sure any code would
>> have the same effect:
>
> If you code is valid XML text, it will work, like the fragment below:
>
>> <script language="JavaScript" type="text/javascript">
>>
>>  var streams = new Array();
>>  var validFPS = new Array(0,1,2,3,4,5,6,7,8,9,10,15,20,25);
>>  var size = new Array();
>
>> So, the question is how/whether I can include inline javascript
>> in a document meant to be processed mostly by epilogue. i.e.
>
> The problem is of course that you have in your Javascript code a "<"
> character at line 116, which is in XML a character indicating the
> beginning of an element, hence the error.
>
> You have two ways of fixing this:
>
> o using an entity instead, i.e. &lt;
>
> o surrounding your Javascript code with a CDATA section, as follows:
>
>   <script language="JavaScript" type="text/javascript">
>     <![CDATA[
>       var streams = new Array();
>       ... etc. ...
>     ]]>
>   </script>
>
> -Erik
>
>

--------------------------------------------------------------------------------


>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
>



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws