Bud said:
Can someone point me to a script that will allow me to implement a
"back button" in an HTA, since there is no history for HTA's.
Understand this requires an array, is there any sample code out there
?
Do not write spaces before sentence marks as it confuses automagic
line-break as you see here.
You will need frames for this quickhack. Put it in the frame documents
(it is best to include the plain JavaScript part in a .js file and link
to it then):
function History(target)
{
var items = [];
var currentItem = 0;
this.goto =
function history_goto(sURL)
{
items[currentItem++] = target.location;
target.location = sURL;
};
this.go =
function history_go(n)
{
if (currentItem + n < 0 || currentItem + n > items.length - 1)
{
if (n < 0)
n = -currentItem;
else
n = items.length - 1 - currentItem;
}
target.location = items[currentItem += n];
};
this.back =
function history_back()
{
this.go(-1);
};
this.forward =
function history_forward()
{
this.go(+1);
};
}
/*
* The non-function properties of the prototype are accessible
* via the function properties, the methods, only. If you need
* direct access, declare them as properties of `this' instead.)
*/
if (parent)
{
if (!parent.history)
// Let the history be a property of the parent frameset;
// navigation affects the location of the current frame (window)
parent.history = new History(window);
}
function checkProp(sProp)
{
return (parent && parent.history && parent[sProp]);
}
function back()
{
if (checkProp("back"))
parent.history.back();
return false;
}
function forward()
{
if (checkProp("forward"))
parent.history.forward();
return false;
}
function goto(sURL)
{
if (checkProp("goto"))
parent.history.goto(sURL);
return false;
}
<a
href="#"
onclick="return back();">Back</a>
<a
href="#"
onclick="return forward();">Forward</a>
...
<a
href="foobar.html"
onclick="return goto(this.href);">Next</a>
HTH
PointedEars