473,737 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2710
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.co m 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.c om, 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.javas cript 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.co m <el****@gmail.c om> 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.co m <el****@gmail.c om> 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 onPropertyChang e 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="javas cript">

// 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.has h != oldloc){
msg("navigation : from:"+oldloc+" to:"+location.h ash);
oldloc=location .hash;
}
}

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

</script>
</head>
<body onload="initial ise()">

<form name="info">
<input name="message" value="Hello!" type="text" style="width:18 em;">
</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.co m <el****@gmail.c om> 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 onPropertyChang e 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 onPropertyChang e 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.co m <el****@gmail.c om> wrote:
Hi Jason,

Thanks you so much for your insight into the matter, you've helped me
alot. You've mentioned that onPropertyChang e doesn't work with
location.hash,
watch (gecko based age) doesn't work (or I used it incorrectly). I
haven't tried onPropertyChang e 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

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

Similar topics

3
10719
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 be able to determine which anchor was clicked on even tho they will all call the same dispatcher.php script - in PHP can I detect which anchor was clicked on once I'm in the dispatcher script? <A HREF="dispatcher.php">2</A>
6
3334
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 is possible to Add and Delete rows - Some cells have special attributes (readonly and events) Here's a snippet of the code:
0
1701
by: jan v | last post by:
Hi everyone I have a problem with events. When the code reaches communication.SynchronisationServer.UpdateNotificationEvent+=new Agilis.RAB.Server.BusinessLogic.SynchronisationDelegate(SynchronisationServer_UpdateNotificationEvent); communication.SynchronisationServer.UpdatedDataSenderEvent+=new Agilis.RAB.Server.BusinessLogic.SynchronisationDataSendingDelegate(SynchronisationServer_UpdatedDataSenderEvent); than it fires the...
4
3013
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) : Inconsistent field declarations in duplicated types (types: GCClass; fields: m_blah): (0x04000001). LINK : fatal error LNK1215: metadata operation failed (80131130) :
6
3249
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: Compilation failed while compiling index.hhk Thanks Paul
5
2721
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 working fine but now I need to add events to the newly created DropDownList controls. I need to add the SelectedIndexChanged event and I'm having a hard time getting the code to add events to the controls since the names (IDs) are varied to include...
2
2567
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 in an OCX) and then passes them on using events. The consumer of these VB6 events is a C# dll using .NET 2.0
0
1129
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 locations. But After printing first page it increase paper 3cm vertically/Height so on second
3
3571
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 example about using Routed Events, he has a loop that assigns an eventhandler to the PreviewKeyUp, etc., events, like this: //these are elements defined in code above this point UIElement els = { win, grid, btn, text }; foreach (UIElement el in els)
0
8786
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9467
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9331
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8203
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6749
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6052
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4567
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2192
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.