[Date Index][Thread Index]
[Date Prev][Date Next][Thread Prev][Thread Next]

Re: Quick bugdrop



On Tue, Jul 18, 2000 at 01:39:10AM -0700, Chris Marston wrote:

> Er, I sent this to rse@engelschall.com, but I'm not sure it got through,
> so I joined the list and am resubmitting it. :)

Hi Chris, Ralf forwarded it to me, but i did not answer yet.

> There seems to be a bug in WML2.0.2's <rollover> (at least, so far as
> interaction with Netscape is concerned). Essentially, since each dhtml layer
> (``absolutely positioned block'', in CSS-speak) is a javascript 'document'
> object in its own right, any javascript it contains cannot see the javascript
> functions of its peers. This means that javascript errors are thrown 
> when code looks like:
> 
> <span id=floatingyogi>
> <rollover ... >
> </span>
> <span id=magicbunny>
> <rollover ... >
> </span>
> 
> 'magicbunny's rollover will complain that the rollover functions cannot
> be found.
> 
> 
> Enclosed is a workaround in mp4h/eperl.
> 
> #workaround for an annoying rollover bug that causes 
> #javascript errors on dhtml netscape docs.
> 
> <define-tag span endtag=required>
> 	<: push @LAYERS, {}; :>
> 	<span* %attributes >
> 	%body
> 	</span*>
> 	<: pop @LAYERS; :>
> </define-tag>
> 
> <define-tag div endtag=required>
> 	<: push @LAYERS, {}; :>
> 	<div* %attributes >
> 	%body
> 	</div*>
> 	<: pop @LAYERS; :>
> </define-tag>
> 
> <define-tag layer endtag=required>
> 	<: push @LAYERS, {}; :>
> 	<layer* %attributes >
> 	%body
> 	</layer*>
> 	<: pop @LAYERS; :>
> </define-tag>
> 
> <define-tag cmarstonRollover whitespace=delete>
> 	<:print q (
> <script type="text/javascript" language="JavaScript">
> <!-- cmarston@trentu.ca: a quick layering patch
> 
> function ro_imgNormal(imgName) {
>     if (document.images) {
>         document[imgName].src = eval(imgName + "_n.src");
>         self.status = '';
>     }
> }
> function ro_imgOver(imgName, descript) {
>     if (document.images) {
>         document[imgName].src = eval(imgName + "_o.src");
>         self.status = descript;
>     }
> }
> --> </script> 
> )  unless (  $LAYERS[$#LAYERS]->{'rolled'} || 
> 	     $LAYERS->{'first'}  );
> $LAYERS[$#LAYERS]->{'rolled'} = 1;
> $LAYERS->{'first'} = 0;
> :>
> <rollover %attributes >
> </define-tag>

This is interesting, but it will fail with multi-lingual documents
(current rollover fail too), e.g.
  <en><rollover ...></en>
  <fr><rollover ...></fr>
Because Javascript functions are present in first language only.

I believe that the best solution is to define
  <define-tag ro:funcs>\
  #   following tag is defined in wml::std::tags
  <javascript>
  function ro_imgNormal(imgName) {
      if (document.images) {
          document[imgName].src = eval(imgName + "_n.src");
          self.status = '';
      }
  }
  function ro_imgOver(imgName, descript) {
      if (document.images) {
          document[imgName].src = eval(imgName + "_o.src");
          self.status = descript;
      }
  }
  </javascript>
  <define-tag ro:funcs></define-tag>\
  </define-tag>

Let <rollover> call this function. When you need to put these functions
more than once, call <ro:funcs> in HEAD section (between
<head>...</head>) either directly or via diversions.

-- 
Denis Barbier
WML Maintainer
______________________________________________________________________
Website META Language (WML)                www.engelschall.com/sw/wml/
Official Support Mailing List                   sw-wml@engelschall.com
Automated List Manager                       majordomo@engelschall.com