473,231 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,231 software developers and data experts.

problem with anchor events, please help!!

Hi,

Is there an event that fires when the back or forward button on a
browser is pressed? I need an event to fire when someone clicks the
back or forward button after an anchor has been set.

Thanks so much for reading about my problem!

H

Dec 30 '05 #1
10 2656
Hi Lee,

I mean that when the url hash changes, or in other words, when the hash
property of the location object changes; more specifically, triggered
from either the forward or back button.

I will elaborate from a user perspective:

You enter a page with anchors, and the hyperlinks to the anchors are at
the top of the page. When you click on the hyperlink, it jumps to the
corresponding anchor, and the anchor hash appears in your address bar
(ie #description). Now, when you click on a few anchor links you begin
to build a history. Using your browser, when you click the back button,
you will begin jumping around the various named anchors you visited
previously.

And so, my question is whether there is a way to trigger a function
when the back and forward buttons are used to navigate between the
named anchors.

I appreciate your attention Lee,

H

Dec 31 '05 #2
el****@gmail.com said the following on 12/30/2005 7:45 PM:

Please quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.

<snip>
And so, my question is whether there is a way to trigger a function
when the back and forward buttons are used to navigate between the
named anchors.


You have no way of programatically knowing whether I clicked the
forward/back buttons or not. Nor will you know if I right clicked and
chose "Forward/Backward".

You can only, minimally, know that I am navigating. Not where I went,
where I came from, nor how I choose to get there.

You could try setting a cookie that tracked the history of the page. But
the approach and idea itself lends to failure.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 31 '05 #3
Hi Randy,

I apologize for the mistake when replying, are there consequences to
the way I replied?

Well, let me describe the specific task that I'm trying to accomplish,
maybe you, or others, could lend some clarity to the limits I'm up
against.

I'm building a tool that will allow actionscript developers to use the
browsers forward and back button to trigger events by using the url
hash as the distinguishing identifier. Using the hash will also allow
for bookmarking, so that when a flash page is revisited, or linked, the
actual content that the end user is attempting to share may be directly
visited.

I have this working: http://www.anticipatechange.com/browserSupport/

use the setAnchor button to set the url hash, then use the back and
forward button to observe the functionality I'm talking about.

My problem is that the back and forward events are triggered by a
setInterval function from within flash that is continually checking the
url hash for differences, and so, when a difference is detected it
triggers an event.

I was hoping there was a way for me to trigger a function call when the
url hash changes, but if that's not possible, given the problem, can
you, or anyone else for that matter, think of a solution to this
problem?

I don't like the idea of having to continually check the url, it is a
terrible work around.

Thanks so much for your attention Randy,

H

Dec 31 '05 #4
On 2005-12-30, el****@gmail.com <el****@gmail.com> wrote:
Hi,

Is there an event that fires when the back or forward button on a
browser is pressed? I need an event to fire when someone clicks the
back or forward button after an anchor has been set.


no. such an event could be misused (eg to keep someone on a page when they
want to leave)

you may have to redesign your application to allow history navigation.

Bye.
Jasen
Dec 31 '05 #5
On 2005-12-31, el****@gmail.com <el****@gmail.com> wrote:
Hi Lee,

I mean that when the url hash changes, or in other words, when the hash
property of the location object changes; more specifically, triggered
from either the forward or back button.

I will elaborate from a user perspective:

You enter a page with anchors, and the hyperlinks to the anchors are at
the top of the page. When you click on the hyperlink, it jumps to the
corresponding anchor, and the anchor hash appears in your address bar
(ie #description). Now, when you click on a few anchor links you begin
to build a history. Using your browser, when you click the back button,
you will begin jumping around the various named anchors you visited
previously.

And so, my question is whether there is a way to trigger a function
when the back and forward buttons are used to navigate between the
named anchors.

I appreciate your attention Lee,


ah... that't different. yes it's possible.

you could set an onInterval event which watches location.hash
and acts when it changes.

in some agents it may be possible to use onPropertyChange or watch
to trigger the event instantaneously. whereas setinverval can only
be almost instantaneous.

here's an example (tested in mozilla only, but should be portable)

<html>
<head>
<script language="javascript">

// I find alert irritating... this puts a message in a form field
function msg(msg){
document.forms['info'].elements['message'].value=msg;
}

var oldloc='';

function check(){
if(location.hash != oldloc){
msg("navigation: from:"+oldloc+" to:"+location.hash);
oldloc=location.hash;
}
}

function initialise()
{
setInterval(check,100); // run check every 100 miliseconds
// that is, 10 times every second.
msg("This is a test");
}

</script>
</head>
<body onload="initialise()">

<form name="info">
<input name="message" value="Hello!" type="text" style="width:18em;">
</form>

<a href="#a">to anchor a</a>
<a href="#b">to anchor b</a>
<a href="#c">to anchor c</a>
<a href="#d">to anchor d</a>
<a href="#e">to anchor e</a>
<a href="#f">to anchor f</a>
<a href="#g">to anchor g</a>
<a href="#h">to anchor h</a>
<br>
<a name="a">a</a><br>
<a name="b">b</a><br>
<a name="c">c</a><br>
<a name="d">d</a><br>
<a name="e">e</a><br>
<a name="f">f</a><br>
<a name="g">g</a><br>
<a name="h">h</a><br>

</body>
</html>


--

Bye.
Jasen
Dec 31 '05 #6
On 2005-12-31, el****@gmail.com <el****@gmail.com> wrote:
Hi Randy,

I apologize for the mistake when replying, are there consequences to
the way I replied?
there can be... it's generally a good idea to quote a little of the mesage
you are replying to so that readers can see immediately what you are
replying to. also replying in context can save you typing
I'm building a tool that will allow actionscript developers to use the
browsers forward and back button to trigger events by using the url
hash as the distinguishing identifier. Using the hash will also allow
for bookmarking, so that when a flash page is revisited, or linked, the
actual content that the end user is attempting to share may be directly
visited.
if you're only interested in where they are currently periodicaly checking
location.hash will give that information.
I was hoping there was a way for me to trigger a function call when the
url hash changes, but if that's not possible, given the problem, can
you, or anyone else for that matter, think of a solution to this
problem?
I just tried watch()ing location.hash and it didn't work... so ignore that
part of me previous post.
I don't like the idea of having to continually check the url, it is a
terrible work around.


yes, but it works, and doesn't consume a great amount of their processor's
power
Bye.
Jasen
Dec 31 '05 #7
Hi Jason,

Thanks you so much for your insight into the matter, you've helped me
alot. You've mentioned that onPropertyChange doesn't work with
location.hash, so I will rule that out as a possibility, however, the
code solution you've written is something I'm very interested in
implementing; would you recommend my using the onInterval function in
building a framework that is demanding of a high level in
compatibility?

The solution you've presented is better than the one I'm currently
using, since no document to object communication will be made, meaning,
I can use true delegation patterns, and in affect is the elimination of
the frequent cross scope communication. As I've said though, every new
javascript member I introduce into the framework must be multi agent
friendly.

I appreciate your attention Jasen,

H

Dec 31 '05 #8
Hi Jason,

Thank you so much for your insight into the matter, you've helped me
alot. You've mentioned that onPropertyChange doesn't work with
location.hash, so I will rule that out as a possibility, however, the
code solution you've written is something I'm very interested in
implementing; would you recommend my using the onInterval function in
building a framework that is demanding of a high level in
compatibility?

The solution you've presented is better than the one I'm currently
using, since no document to object communication will be made, meaning,
I can use true delegation patterns, and in affect is the elimination of
the frequent cross scope communication. As I've said though, every new
javascript member I introduce into the framework must be multi agent
friendly.

I appreciate your attention Jasen,

H

Dec 31 '05 #9
On 2005-12-31, el****@gmail.com <el****@gmail.com> wrote:
Hi Jason,

Thanks you so much for your insight into the matter, you've helped me
alot. You've mentioned that onPropertyChange doesn't work with
location.hash,
watch (gecko based age) doesn't work (or I used it incorrectly). I
haven't tried onPropertyChange as I'm not prepared to comply with all
the requirements needed to access the documentation.
so I will rule that out as a possibility, however, the
code solution you've written is something I'm very interested in
implementing; would you recommend my using the onInterval function in
building a framework that is demanding of a high level in
compatibility?
setInterval
AFAIK it's supported by all the popular agents.
The solution you've presented is better than the one I'm currently
using, since no document to object communication will be made, meaning,
I can use true delegation patterns, and in affect is the elimination of
the frequent cross scope communication. As I've said though, every new
javascript member I introduce into the framework must be multi agent
friendly.


There's too many unfamiliar terms in there for me to understand it fully.
I started coding javascript just after easter last year. before that it was
a mix of other (mainly non-00) compiled and interpreted languages.

Bye.
Jasen
Jan 1 '06 #10
Thanks Jasen, you've been a great help.

H

Jan 2 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ralph Freshour | last post by:
I'm using PHP and while this is an HTML question, I'm looking for a PHP answer please - I've got several anchors similar to the one shown below - I'm calling a dispatcher.php script and I need to...
6
by: Thomas | last post by:
Hi, I'm having a problem with the dynamically created inputfields in Internet Explorer. The situation is the following: - I have a dynamically created table with a textbox in each Cell. - It...
0
by: jan v | last post by:
Hi everyone I have a problem with events. When the code reaches communication.SynchronisationServer.UpdateNotificationEvent+=new...
4
by: Gary Hughes | last post by:
Hi all, sometime I posted a problem in here where I was getting the following error from the linker in VS C++ 2003. Linking... GCClass.obj : error LNK2022: metadata operation failed (80131188)...
6
by: Paul | last post by:
Not sure if this is the correct place to post the problem, but trying to use the HTML help workshop and trying to create the index file automatically. Anyhow I get the error below HHC5003: Error:...
5
by: Steve Moreno | last post by:
Hi all, I've got a web form that I've written code to create an array of DropDownList controls on the page depending on how many records are pulled back. The code to create the controls is...
2
by: hakan_cn | last post by:
Hi all! Sorry for the cross-post, I really have a difficult problem and need some help badly. I have a VB6 ActiveX component (dll) that listens to a real-time data feed of stock quotes (built...
0
by: Sukh | last post by:
Hi I am stuck with a problem Can anyone help me out from this... I am printing a report on pre-printed continue paper using dot-matrix printer using vb.net. Data is printing on all the...
3
by: RobinS | last post by:
I'm trying to learn WPF and do it in VB instead of C#. (God forbid I should do *anything* the easy way. ;-) Here's something weird. On p162-3 of this book by Petzold (in C# of course) in an...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.