Re: [WSG] injecting an extra hook with javascript

2005-11-02 Thread James Gollan
You mentioned that you wanted to be able to see it when you view the 
source - is that important? Because you wont *see* the span element but 
the browser will. (I imagine you are doing this for an image replacement 
technique in which case not seeing it wouldn't be a big issue). Remember 
you need to call the function, for example


body onload=insertSpan()

Dustin Diaz wrote:


function insertSpan() {
 if ( !document.getElementById || !document.createElement ) {
   return;
 }
 var util = document.getElementById('utilities');
 var links = util.getElementsByTagName('a');
 for ( i=0;ilinks.length;i++ ) {
   var span = document.createElement('span');
   links[i].appendChild(span);
 }
}


Dustin


On 11/1/05, Peter Ottery [EMAIL PROTECTED] wrote:
 


just say i have markup like this:

--
div id =utility
ul
lia href=List Item/a/li
lia href=List Item/a/li
lia href=List Item/a/li
/ul
/div
-

and for one reason or another I *dont* have access to the html markup.
Then an intricate design comes along that requires an extra hook (a span
tag) to be inserted inside each a href/a tag.
is it possible to use javascript (1) to insert a span tag inside each a
href on the fly so its not in the markup - but would be there if you were
able to view the rendered source? you know what i mean - dynamically
changing the dom... or something

can you tell i know nothing about javascript? :)

any help appreciated.

cheers, pete

(1) - of course, without javascript list items would still be accessible -
they just wouldnt have the nice design inticacies



   


**
The discussion list for  http://webstandardsgroup.org/

See http://webstandardsgroup.org/mail/guidelines.cfm
for some hints on posting to the list  getting help
**




 


**
The discussion list for  http://webstandardsgroup.org/

See http://webstandardsgroup.org/mail/guidelines.cfm
for some hints on posting to the list  getting help
**



Re: [WSG] injecting an extra hook with javascript

2005-11-02 Thread Joshua Street
On 11/2/05, James Gollan [EMAIL PROTECTED] wrote:
 You mentioned that you wanted to be able to see it when you view the
 source - is that important? Because you wont *see* the span element but
 the browser will. (I imagine you are doing this for an image replacement
 technique in which case not seeing it wouldn't be a big issue). Remember
 you need to call the function, for example

 body onload=insertSpan()

Would

window.onload = function(){if(document.getElementById) insertSpan();}

be a better alternative? I don't know much about this but that strikes
me as potentially separating content and behaviour a little bit
more...? (Heh, even if this is to achieve content... but it's a good
thing because it means less redundant code, I guess!)

Also

var util = document.getElementById('utilities');

should be

var util = document.getElementById('utility');

according to Peter's original markup. Just thought I'd point that out.

regards,

Josh

--
Joshua Street

http://www.joahua.com/
+61 (0) 425 808 469
**
The discussion list for  http://webstandardsgroup.org/

 See http://webstandardsgroup.org/mail/guidelines.cfm
 for some hints on posting to the list  getting help
**



Re: [WSG] injecting an extra hook with javascript

2005-11-02 Thread Anders Nawroth



James Gollan skrev:

You mentioned that you wanted to be able to see it when you view the 
source - is that important?



http://jennifermadden.com/scripts/ViewRenderedSource.html

FF extension to see the rendered source !

/AndersN
**
The discussion list for  http://webstandardsgroup.org/

See http://webstandardsgroup.org/mail/guidelines.cfm
for some hints on posting to the list  getting help
**



Re: [WSG] injecting an extra hook with javascript

2005-11-02 Thread Dustin Diaz
I completely dooced the onload. If you're using one of the infamous
addEvent methods, you could just do this:

addEvent(window,'load',insertSpan);

Dustin

On 11/2/05, Anders Nawroth [EMAIL PROTECTED] wrote:


 James Gollan skrev:

  You mentioned that you wanted to be able to see it when you view the
  source - is that important?


 http://jennifermadden.com/scripts/ViewRenderedSource.html

 FF extension to see the rendered source !

 /AndersN
 **
 The discussion list for  http://webstandardsgroup.org/

  See http://webstandardsgroup.org/mail/guidelines.cfm
  for some hints on posting to the list  getting help
 **


**
The discussion list for  http://webstandardsgroup.org/

 See http://webstandardsgroup.org/mail/guidelines.cfm
 for some hints on posting to the list  getting help
**



[WSG] injecting an extra hook with javascript

2005-11-01 Thread Peter Ottery
just say i have markup like this:

--
div id =utility
ul

lia href="" Item/a/li

lia href="" Item/a/li

lia href="" Item/a/li

/ul
/div
-

and for one reason or another I *dont* have access to the html markup.
Then an intricate design comes along that requires an extra hook (a
span tag) to be inserted inside each a href/a tag.
is it possible to use _javascript_ (1) to insert a span tag
inside each a href on the fly so its not in the markup - but would be
there if you were able to view the rendered source? you know what i
mean - dynamically changing the dom... or something

can you tell i know nothing about _javascript_? :)

any help appreciated.

cheers, pete

(1) - of course, without _javascript_ list items would still be accessible - they just wouldnt have the nice design inticacies




Re: [WSG] injecting an extra hook with javascript

2005-11-01 Thread Dustin Diaz
function insertSpan() {
  if ( !document.getElementById || !document.createElement ) {
return;
  }
  var util = document.getElementById('utilities');
  var links = util.getElementsByTagName('a');
  for ( i=0;ilinks.length;i++ ) {
var span = document.createElement('span');
links[i].appendChild(span);
  }
}


Dustin


On 11/1/05, Peter Ottery [EMAIL PROTECTED] wrote:
 just say i have markup like this:

  --
  div id =utility
  ul
  lia href=List Item/a/li
  lia href=List Item/a/li
  lia href=List Item/a/li
  /ul
  /div
  -

  and for one reason or another I *dont* have access to the html markup.
  Then an intricate design comes along that requires an extra hook (a span
 tag) to be inserted inside each a href/a tag.
  is it possible to use javascript (1) to insert a span tag inside each a
 href on the fly so its not in the markup - but would be there if you were
 able to view the rendered source? you know what i mean - dynamically
 changing the dom... or something

  can you tell i know nothing about javascript? :)

  any help appreciated.

  cheers, pete

  (1) - of course, without javascript list items would still be accessible -
 they just wouldnt have the nice design inticacies



**
The discussion list for  http://webstandardsgroup.org/

 See http://webstandardsgroup.org/mail/guidelines.cfm
 for some hints on posting to the list  getting help
**