Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 20th, 2005, 12:29 PM
Bud Zielinski
Guest
 
Posts: n/a
Default Enable Back Button feature in an HTA

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
?

thanks

Bud
  #2  
Old July 20th, 2005, 01:05 PM
Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a
Default Re: Enable Back Button feature in an HTA

Bud Zielinski wrote:
[color=blue]
> 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
> ?[/color]

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
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles