B
Bob Phillips
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.getElementsByTagName('meta');
if (debug) alert('[setMetaContent] metaTag='+metaTag+' metaName=
'+metaName+' value '+value);
for (var i=0; i<metas.length; i++) {
if (metas.getAttribute(metaTag)==metaName)
break;
}
if (debug) alert('[setMetaContent] i='+i+' value '+value);
metas.setAttribute('content',value);
}
and I call it with
var metaValue = '10;url='+rootSource+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.getElementsByTagName('meta');
if (debug) alert('[setMetaContent] metaTag='+metaTag+' metaName=
'+metaName+' value '+value);
for (var i=0; i<metas.length; i++) {
if (metas.getAttribute(metaTag)==metaName)
break;
}
if (debug) alert('[setMetaContent] i='+i+' value '+value);
metas.setAttribute('content',value);
}
and I call it with
var metaValue = '10;url='+rootSource+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