473,699 Members | 2,550 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get urls from hyperlinks

manuelgk
54 New Member
Hi everybody, I'm a total beginner using Javascript and I would like to know how can I get in a variable the url of hyperlinks? I want to do something like a status bar of mozilla (not a bar) but just get the urls no matter the extension of the hyperlinks (.html, .php, .pdf, etc). So please I need your help :) . Thanks
Sep 13 '07 #1
15 2799
dmjpro
2,476 Top Contributor
Hi everybody, I just a total beginner using Javascript and I would like ti know how can I get in a variable the url of hyperlinks? I want to do something like a status bar of mozilla (not a bar) but just get the urls no matter the extension of the hyperlinks (.html, .php, .pdf, etc). So please I need your help :) . Thanks

Welcome to TSDN!
There is an attribute href of a Tag.
Try to access this.

Have an example.
Expand|Select|Wrap|Line Numbers
  1. var links = document.links;
  2. for(var i=0;i<links.length;i++)
  3.  alert(links[i].getAttribute('href'));
  4.  
Good Luck.

Kind regards,
Dmjpro.
Sep 13 '07 #2
manuelgk
54 New Member
Thank you, but as I say I'm a total beginner (hehehe) so my next question is where can I try it? XD.
Sep 13 '07 #3
epots9
1,351 Recognized Expert Top Contributor
Thank you, but as I say I'm a total beginner (hehehe) so my next question is where can I try it? XD.
on a HTML page with all the <a> tags with the name "links"
Sep 13 '07 #4
Death Slaught
1,137 Top Contributor
Try going here it's a tutorial on javascript.
Sep 13 '07 #5
manuelgk
54 New Member
Thanks everybody, I follow all the advices and read the javascript tutorial, they were really useful. However, it seems like js only accept (as the first suggestion) the <a> tags with an specific URL in a Web page. My objetive is make a extension for a navigator (Mozilla), it should detect the hyperlinks no matter the web page I open. I need to take the URL's from the hyperlinks (as a status bar) and modify or send an alert before the client access the Web page. As I tell you before, the detection of the hyperlinks must be in any page of the Web. So I don't know if js is the correct option for do that or should I do it in another programming language?.
Thanks again for your help, and I'm sorry if I do stupid questions hehehe!
Sep 18 '07 #6
Death Slaught
1,137 Top Contributor
Thanks everybody, I follow all the advices and read the javascript tutorial, they were really useful. However, it seems like js only accept (as the first suggestion) the <a> tags with an specific URL in a Web page. My objetive is make a extension for a navigator (Mozilla), it should detect the hyperlinks no matter the web page I open. I need to take the URL's from the hyperlinks (as a status bar) and modify or send an alert before the client access the Web page. As I tell you before, the detection of the hyperlinks must be in any page of the Web. So I don't know if js is the correct option for do that or should I do it in another programming language?.
Thanks again for your help, and I'm sorry if I do stupid questions hehehe!
Np it's what we're here for, and there's no such thing as a stupid question, we all had them once upon a time.

- Death
Sep 18 '07 #7
acoder
16,027 Recognized Expert Moderator MVP
Thanks everybody, I follow all the advices and read the javascript tutorial, they were really useful. However, it seems like js only accept (as the first suggestion) the <a> tags with an specific URL in a Web page. My objetive is make a extension for a navigator (Mozilla), it should detect the hyperlinks no matter the web page I open. I need to take the URL's from the hyperlinks (as a status bar) and modify or send an alert before the client access the Web page. As I tell you before, the detection of the hyperlinks must be in any page of the Web. So I don't know if js is the correct option for do that or should I do it in another programming language?.
Javascript would only work within the current page. How are you accessing the URLs? Can you give a complete example of hat you are trying to do? Also note that Javascript cannot be used for cross-domain scripting.
Sep 19 '07 #8
gits
5,390 Recognized Expert Moderator Expert
hmmmm ...

but for an extension you may retrieve the references and build up your own list ... even your own page from it ... so you may do whatever you want with that after 'making it your own' :) ... it could act like a content filter ... what i would assume that the extension should be for?

kind regards
Sep 19 '07 #9
manuelgk
54 New Member
Ok guys thanks for help me again, I was discussing with my professor about the possibility to create this, and we concluded that javascript is a language for extend the functionality of html, so the hyperlinks must have a reference (<a href></a>), thus, is impossible to be in a Web site or Web page if we don't know the direction. In other words, it happens when we want to know how a place look like and we'd never been in that place, even worse if we don't have the address, obius we never know exactly how it looks!!!, that's why we need references about where we want to go before modify something in the fuction. So my new question is how can I know the thing that I'm click is a hyperlink? do the event hadler (onmouseover, onclick) help me?
Thanks for your help again and I'm sorry if I cannot answer before... XD
Greetings from Mexico for every one!!!!
Sep 24 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

22
4321
by: Justin Koivisto | last post by:
OK, I found a thread that help out from a while back (Oct 9, 2002) to give me this pattern: `(((f|ht)tp://)((+)(+)?@)?()+(:\d+)?(\/+)?)`i OK, all is well and good with this until the URL is used at the end of a sentance. I am assuming that I will need a negative lookahead somehow, but I just can't wrap my mind around this one... Want to match only the URL...
3
4662
by: Philip Herlihy | last post by:
I'm using a number of hyperlinks on an Intranet I'm developing which refer to documents on a network server. The URLs I'm using have the form: file://<server>/<path>/<file>.pdf <server> is an UNC path, like: \\hostname They work perfectly in IE, but not in Opera or Firefox. I can't see any reason why not - is the form correct? Any other ideas? --
5
1197
by: Mark Rae | last post by:
Hi, I've been asked to write an ASP.NET app which uses traditional hyperlinks with querystrings for navigation e.g. http://<site>/customers/customer.aspx?id=123 The client wants the querystrings to be encrypted, sort of like Amazon.com does. That's fine - no problem there. However, the client now asks if there is any way of detecting whether the
12
1659
by: MARTIN LANNY | last post by:
Hi All, In my program I am loading the content of a text file (main.txt) into a string called 'message'. What I need is to convert all urls and emails in this string into html. This is what I did to convert hard returns to <br>'s and it works fine: Dim sws As New IO.StreamWriter(pathtosave)
2
1351
by: laredotornado | last post by:
Hello, I want to take a block of text and add html tags to make hyperlinks where hyperlink strings exist. So, if I have a variable $a = "This is http://www.yahoo.com" I would like to run that through a function such that the value of $a is
4
4242
by: Seefor | last post by:
Hi, I want my text hyperlinks to have a dotted border underneath, so I did this which works fine: a, a:link, a:visited, a:hover, a:active { color: #000; text-decoration: none;
1
2371
by: Robin | last post by:
Hello! I'm having trouble with links and hyperlinks in MS Access 2003 - any help would be great! Question 1! The "insert hyperlink" icon opens a browser window, allows the user to browse to the desired file and paste the hyperlink on the form (which obviously remains for on all the records). I am trying to create a
1
3645
by: Janna | last post by:
Hello tech savvy gurus! I hope someone can help me! THE PROBLEM: "Cannot open specified file" when I click on a hyperlink in an Access database when it is located on our server. THE BACKGROUND: I created a folder "Document Library" on my local drive, which contains document sub-folders and the database. For referential integrity, I designed the database with relative hyperlinks (e.g. Folder\File.pdf). The hyperlinks worked perfectly...
4
843
by: =?Utf-8?B?UGF1bA==?= | last post by:
I have a web app that allows the user to create a list of urls. I am currently have a textbox the user inputs the URL in one at a time and then a button that when clicked adds the link to a dropdown list. Then for the dropdown selected event I set the URL of a link button to the selected value in the list. Just wondering if you can have a dropdown list of hyperlinks? thanks! -- Paul G Software engineer.
0
8704
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
8623
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,...
1
8940
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8895
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
7781
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
6546
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
5879
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
4637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3071
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.