473,756 Members | 3,655 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Activating a link

I have a list of links using the following construct:

<a href='#artane' onclick='pos(11 07,281)'>Artane </a>

The links offer additional functionality through JS. There are no actual
fragment IDs on the page, but the fragment coding allow the links to be
bookmarked. Via the window.onload event I check if a fragment ID is
present in the address, if so I need to activate the 'pos' function with
the appropriate arguments.

I'd like to loop through the links, if one has a href attribute value
that matches the window.location .hash value I'd like to activate that
link so as to avoid having to duplicate the 'pos' function's arguments
within the JS itself.

Am I going about this in an appropriate manner? If so I could use a
pointer to the JS feature that I need to activate an HTML link.

(As is probably obvious I know very little about JS)

--
Spartanicus
Oct 2 '06 #1
3 1629
Spartanicus wrote:
I have a list of links using the following construct:

<a href='#artane' onclick='pos(11 07,281)'>Artane </a>

The links offer additional functionality through JS.
There are no actual fragment IDs on the page, but the
fragment coding allow the links to be bookmarked. Via
the window.onload event I check if a fragment ID is
present in the address, if so I need to activate the
'pos' function with the appropriate arguments.

I'd like to loop through the links, if one has a href
attribute value that matches the window.location .hash
value I'd like to activate that link so as to avoid
having to duplicate the 'pos' function's arguments
within the JS itself.
There is traditional (and W3C formaised) - document.links - collection
that includes all the links in a document. That could be iterated through
checking the - href - properties of the objects found. Those - href -
properties should be expected (but not required) to be normalised to
fully qualified URLs, so use - indexOf - (or similar) instead of straight
comparison.

The objects in the links collection may have (and will have is the HTML
attribute exists) an - onclick - property that is a reference to the
function that the browser generates from the HTML attribute. You may call
that function as a method of the object, in exactly the same way as the
browser would in response to an event. And as you are not using the event
object in the attribute code you will not even have to worry about faking
an event object.

For example, the onclick handler for the fist link on a page may be
called as:-

document.links[0].onclick();

This will indirectly execute your - pos - function with the arguments
used in the HTML attribute's call. However, it will _not_ navigate the
document, but as the fragment identifier is apparently already on the URL
at this point not having it added by navigation should make no
difference.

On the other hand if you wanted to call the - onclick - handler and then
navigate the document to the fragment identifier you could write a
modified URL to the - location - object, or assign the fragment
identifier to - location.hash -.
Am I going about this in an appropriate manner?
<snip>

Difficult to say without the mechanics of the 'why?'.

Richard.
Oct 3 '06 #2
"Richard Cornford" <Ri*****@litote s.demon.co.ukwr ote:
>There is traditional (and W3C formaised) - document.links - collection
that includes all the links in a document. That could be iterated through
checking the - href - properties of the objects found. Those - href -
properties should be expected (but not required) to be normalised to
fully qualified URLs, so use - indexOf - (or similar) instead of straight
comparison.
[snip]

I managed to get it working using your information.
>Am I going about this in an appropriate manner?

Difficult to say without the mechanics of the 'why?'.
This is what the code was for:
http://homepage.ntlworld.ie/spartanicus/temp/

At this stage it is only a coding experiment which has some use for
myself hosted locally. It is not currently suitable for internet
deployment, nor does it offer much functionality likely to be useful to
others. I may later try to make it suitable and more useful for internet
deployment, the sub linking feature was the first issue towards that aim
that I wanted to tackle.

--
Spartanicus
Oct 4 '06 #3

Spartanicus wrote:
"Richard Cornford" <Ri*****@litote s.demon.co.ukwr ote:
There is traditional (and W3C formaised) - document.links - collection
that includes all the links in a document. That could be iterated through
checking the - href - properties of the objects found. Those - href -
properties should be expected (but not required) to be normalised to
fully qualified URLs, so use - indexOf - (or similar) instead of straight
comparison.

[snip]

I managed to get it working using your information.
Am I going about this in an appropriate manner?
Difficult to say without the mechanics of the 'why?'.

This is what the code was for:
http://homepage.ntlworld.ie/spartanicus/temp/

At this stage it is only a coding experiment which has some use for
myself hosted locally. It is not currently suitable for internet
deployment, nor does it offer much functionality likely to be useful to
others. I may later try to make it suitable and more useful for internet
deployment, the sub linking feature was the first issue towards that aim
that I wanted to tackle.

--
Spartanicus
I really liked the page in the "example" link. I would think that the
site could be very popular to people interested in the city of Dublin
and for navigation thereof. Well designed and good navigation
techniques.

Info_Junkie

Oct 5 '06 #4

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

Similar topics

4
2093
by: Bill | last post by:
Is it possible to somehow activate a page containing a php script by sending an email to a mailbox on the server? I have a script that sends out notification emails to an individual. He wants to receive them continuously until he decides he has seen enough of them. Then to stop receiving the emails he has to use his browser and go to the web page that is sending him the emails where he clicks a button. Would it be possible to arrange...
3
1594
by: Ruskin Hardie | last post by:
Ok, I am still playing with ASP and was wondering how to do this (it seemed simple). What I want is to have a hyperlink that when it's clicked on, will run a sub routine, instead of opening a web page... Right now I have; Sub CreateLinks() Response.Write "<br><br>" Response.Write "<a href='OpenAllOrders()'>1. All Orders</a><br>" Response.Write "<a href='OpenCustOrders()'>2. Customer Orders</a><br>" Response.Write "<a...
1
2661
by: Jeppe 1971 | last post by:
Hi Does anyone know of a way to load a HTML-page and examine the document without activating the code? I am trying to create a search-function in javascript. The idea is that the function goes through all the HTML-pages on a site looking for words entered by the user. The results is thereafter presented to the user (it's a kind of a search-engine).
6
3627
by: SF RVN | last post by:
Hmmmm.. a wee bit of a problem: Background default.htm has a left-aligned table serving as a 'navigation menu' and a right-aligned iFrame (named 'viewframe') serving as the 'target' for left-side menu. I think of iFrame as 'child page'. Example: Clicking a left menu item (link to initiation.htm) loads initiation.htm in iFrame. iFrame height is automatically adjusted by SCRIPT LOCATED
12
2078
by: magmike | last post by:
When users of my site submit articles to our database (http://www.netterweb.com/articles/) they almost always have http:// addresses within the text. They are pasting that text into a box which saves to a memo field. When displayed through results on a webpage, the links are inactive, unless the user was knowledgable enough to use html within the text. However, most of my users are not html savvy. Is there a way I can code the results of...
12
3802
by: ppcguy | last post by:
i've got a link that i give focus to via accesskey. <a href="blah" accesskey=p> in IE, that just gives it focus, but does not activate it. how do i activate the link. thx.
10
4079
by: Carlos Araya | last post by:
I have the following link on a web page <p class="menuitem"><a href="#" onclick="loadFragment('http://rivendellweb.net/fortress/home', 'index')" title="The Fortress Home">The Fortress Home</a></p>
0
9456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9872
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
9711
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8712
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
7244
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
6534
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
5303
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
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.