Bob,

on Tuesday, December 6, 2005 at 18:57 wsg@webstandardsgroup.org wrote:

> These connected to a linked JS in the <head>:

> 1. <a href="http://www.fotografics.it"; onclick="popUp 
> (this.href,'elastic',500,650);return false;">&nbsp;powered by:  
> FotoGrafics</a>

<a href="http://www.fotografics.it"; 
rel="popUp(type=elastic;width=500;height=650)">&nbsp;powered by: FotoGrafics</a>

In an external JavaScript:

var links = document.getElementsByTagName("a");
for(var i=0; i<links.length;i++) {
  if(links[i].getAttribute("rel")) {
    var relation = getRelation(links[i]);
    var params = getParams(links[i]);
    switch(relation) {
      case 'popUp':
        links[i].onclick = new Function("return 
!popUp('"+links[i].getAttribute("href")+"','"+params['type']+"','"+params['width']+"','"+params['height']+"');");
        links[i].setAttribute("title","Link opens new window");
        break;
    }
  }
}

function getRelation(obj) {
  var rel=obj.getAttribute("rel");
  if(!rel)return false;
  return rel.indexOf("(")==-1?rel:rel.substring(0,rel.indexOf("("));
}
        
function getParams(obj) {
  var rel=obj.getAttribute("rel");
  if(!rel)return false;
  if(rel.indexOf("(")==-1||rel.indexOf(")")==-1) return [];
  var pliste = rel.substring(rel.indexOf("(")+1,rel.indexOf(")"))
  var result = [];
  var parameter = pliste.split(";");
  for(var i=0;i<parameter.length;i++) {
    var nameValue = parameter[i].split("=");
    result[nameValue[0]]=nameValue[1];
  }
  return result;
}

This isn't perfect, but at least a start. Probably it is better to use
the class attribute. The rest could also be done simpler and faster...
I'm far from being a JavaScript-Guru ;-)

> 2. <div id="home"><a href="#" tabindex="1" onfocus="P7_trigNV 
> ('p7NVim10')" onblur="P7_trigNV()" onmouseover="P7_trigNV 
> ('p7NVim10')" onmouseout="P7_trigNV()"><img src="as/im/v2_01.jpg"  
> alt="" width="88" height="25" id="p7NVim10" /></a></div>

Do you have a page where we can see what should happen?

> 3. <body onload="P7_setNV('p7NVim10',2);P7_trigNV()">

http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html

But with all the comments...

Then:

addEvent(body,'load',function() { P7_setNV('p7NVim10',2) });
addEvent(body,'load',P7_trigNV);

> This one all alone on the page, with no linked JS in the <head>:

> <div id="copy">
> <script type="text/javascript">
> var d=new Date();
> yr=d.getFullYear();
> if (yr!=2003)
> document.write("&copy; "+yr);
> </script>&nbsp;Cedar Tree Books
> </div>

Do it on the serverside!!!

regards

  Martin

 



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

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

Reply via email to