Hope someone can help.
I am struggling to write an meta element in JS. The meta element in question
is the refresh element.
This is the code I am using
//--------------------------------------------------------------------------
----
function setMetaContent( metaTag, metaName, value) {
//--------------------------------------------------------------------------
----
var metas = document.getEle mentsByTagName( 'meta');
if (debug) alert('[setMetaContent] metaTag='+metaT ag+' metaName=
'+metaName+' value '+value);
for (var i=0; i<metas.length ; i++) {
if (metas[i].getAttribute(m etaTag)==metaNa me)
break;
}
if (debug) alert('[setMetaContent] i='+i+' value '+value);
metas[i].setAttribute(' content',value) ;
}
and I call it with
var metaValue = '10;url='+rootS ource+fileBase+ aryChile[nImgId][4]+'.html';
if (debug) alert('[writeIMG] metaValue ='metaValue);
setMetaContent( 'http-equiv','refresh ',metaValue);
where rootSource = "../source/", fileBase = "picture", and
aryChile[nImgId][4] resolves to an integer . The url setup looks okay, but
the code seems to disappear intgo oblivion.
Two questions
1) can I set a meta element in this way
2) does the code look correct?
TIA
Bob
I am struggling to write an meta element in JS. The meta element in question
is the refresh element.
This is the code I am using
//--------------------------------------------------------------------------
----
function setMetaContent( metaTag, metaName, value) {
//--------------------------------------------------------------------------
----
var metas = document.getEle mentsByTagName( 'meta');
if (debug) alert('[setMetaContent] metaTag='+metaT ag+' metaName=
'+metaName+' value '+value);
for (var i=0; i<metas.length ; i++) {
if (metas[i].getAttribute(m etaTag)==metaNa me)
break;
}
if (debug) alert('[setMetaContent] i='+i+' value '+value);
metas[i].setAttribute(' content',value) ;
}
and I call it with
var metaValue = '10;url='+rootS ource+fileBase+ aryChile[nImgId][4]+'.html';
if (debug) alert('[writeIMG] metaValue ='metaValue);
setMetaContent( 'http-equiv','refresh ',metaValue);
where rootSource = "../source/", fileBase = "picture", and
aryChile[nImgId][4] resolves to an integer . The url setup looks okay, but
the code seems to disappear intgo oblivion.
Two questions
1) can I set a meta element in this way
2) does the code look correct?
TIA
Bob
Comment