I have this little utility function that returns the PageDiv if it exists, ready for extending.
function GetPageDiv(){
var divs = fwDocument.fwTags.fwFindAll('div');
for (i in divs){
if (divs[i].id && divs[i].id.toString() == '"PageDiv"') return divs[i];
}
return false;
}
Is there a simpler way to do this that I’m overlooking?
function GetPageDiv(){
var div = fwDocument.fwTags.fwFind("body").fwFind("div");
if (div.id && divs[i].id.toString() == '"PageDiv"')
return div;
else
return false;
}
Joe
On 1 Jul 2008, at 15:20, waltd wrote:
I have this little utility function that returns the PageDiv if it
exists, ready for extending.
function GetPageDiv(){
var divs = fwDocument.fwTags.fwFindAll(‘div’);
for (i in divs){
if (divs[i].id && divs[i].id.toString() == ‘“PageDiv”’) return
divs[i];
}
return false;
}
Is there a simpler way to do this that I’m overlooking?
Hi Walter,
You could try and sped things up by doing a "I’m feeling lucky’ version of the action;
function GetPageDiv(){
var firstdiv = fwDocument.fwTags.fwFind(‘div’);
if (firstdiv){
if (firstdiv.id && firstdiv.id.toString() == ‘“PageDiv”’) return firstdiv;
}
return false;
}
This would cut down on the looping through the divs but may not find the PageDiv (an action could add a parent div in there) although ‘most’ of the time the 1st div is the one you are looking for.
Generally I think the way you are doing things is how I would tackle the issue.
Regards,
Tim.
On 1 Jul 2008, at 07:20, waltd wrote:
I have this little utility function that returns the PageDiv if it exists, ready for extending.
function GetPageDiv(){
var divs = fwDocument.fwTags.fwFindAll(‘div’);
for (i in divs){
if (divs[i].id && divs[i].id.toString() == ‘“PageDiv”’) return divs[i];
}
return false;
}
Is there a simpler way to do this that I’m overlooking?
But then again, if any Actions have added any divs between the body
and the PageDiv it won’t…
On 1 Jul 2008, at 16:12, Joe Billings wrote:
This would also work:
function GetPageDiv(){
var div = fwDocument.fwTags.fwFind(“body”).fwFind(“div”);
if (div.id && divs[i].id.toString() == ‘“PageDiv”’)
return div;
else
return false;
}
Joe
On 1 Jul 2008, at 15:20, waltd wrote:
I have this little utility function that returns the PageDiv if it
exists, ready for extending.
function GetPageDiv(){
var divs = fwDocument.fwTags.fwFindAll(‘div’);
for (i in divs){
if (divs[i].id && divs[i].id.toString() == ‘“PageDiv”’) return
divs[i];
}
return false;
}
Is there a simpler way to do this that I’m overlooking?