473,412 Members | 3,860 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,412 software developers and data experts.

Can I use js to fetch title of remote url?


Folks,

I know javascript has no local or server based access to the disk however I
was wondering if one can read a remote page and take its html <TITLE>
value...

My guess is no but thought I'd check/ask anyway...

Thanks,
randelld
Jul 20 '05 #1
6 7352
Hi,

Randell D. wrote:
Folks,

I know javascript has no local or server based access to the disk however I
was wondering if one can read a remote page and take its html <TITLE>
value...

My guess is no but thought I'd check/ask anyway...

Thanks,
randelld


You're mixing two things. While it's true that client-side JavaScript,
under normal security environment (i.e. executed in a browser from the
web and without special security settings) is unable to read from the
local disk, it has nothing to do with it's unability to extract other
pages' attributes. This is the so-called "same origin policy" which
prevents it to do so. In short, JavaScript can access pages originating
from the same domain only. Now, some browsers are more relaxed about
this than others, but to be on the safe side, you should accept that
this is impossible if both pages are not on the same domain.

If the pages are on the same domain, then you can read (and set, on
newer browsers) the document.title property.

HTH,

Laurent
--
Laurent Bugnion, GalaSoft
Webdesign, Java, javascript: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 20 '05 #2
N/A
You can always create an XML HTTP request object (assuming the remote PC has
MS XML installed) and use it to read in the contents of the remote page,
then parse it for the <TITLE> block...

"Randell D." <yo**************************@yahoo.com> wrote in message
news:AX***********************@news3.calgary.shaw. ca...

Folks,

I know javascript has no local or server based access to the disk however I was wondering if one can read a remote page and take its html <TITLE>
value...

My guess is no but thought I'd check/ask anyway...

Thanks,
randelld

Jul 20 '05 #3

"Laurent Bugnion, GalaSoft" <galasoft-LB@bluewin_NO_SPAM.ch> wrote in
message news:3F1246CB.1020604@bluewin_NO_SPAM.ch...
Hi,

Randell D. wrote:
Folks,

I know javascript has no local or server based access to the disk however I was wondering if one can read a remote page and take its html <TITLE>
value...

My guess is no but thought I'd check/ask anyway...

Thanks,
randelld


You're mixing two things. While it's true that client-side JavaScript,
under normal security environment (i.e. executed in a browser from the
web and without special security settings) is unable to read from the
local disk, it has nothing to do with it's unability to extract other
pages' attributes. This is the so-called "same origin policy" which
prevents it to do so. In short, JavaScript can access pages originating
from the same domain only. Now, some browsers are more relaxed about
this than others, but to be on the safe side, you should accept that
this is impossible if both pages are not on the same domain.

If the pages are on the same domain, then you can read (and set, on
newer browsers) the document.title property.

HTH,

Laurent
--
Laurent Bugnion, GalaSoft
Webdesign, Java, javascript: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch


Thanks for that... I am writing a publication type system in PHP and offer
the user to option of entering optional links related to the article they
are entering... I know I could have PHP fetch the page title of the remote
page but I would have prefered to have the client PC to perform the fetch -
If I am to understand you above, I would not (legally) be able to use
javascript to read the title of the link since it will not be on the local
domain... I'll stick with PHP for the chore.

Thanks for the info though - I hadn't realised that there was the
opportunity to read a same domain page using javascript.

randelld
Jul 20 '05 #4

"N/A" <no*@here.com> wrote in message
news:jE****************@news-server.bigpond.net.au...
You can always create an XML HTTP request object (assuming the remote PC has MS XML installed) and use it to read in the contents of the remote page,
then parse it for the <TITLE> block...

"Randell D." <yo**************************@yahoo.com> wrote in message
news:AX***********************@news3.calgary.shaw. ca...

Folks,

I know javascript has no local or server based access to the disk
however I
was wondering if one can read a remote page and take its html <TITLE>
value...

My guess is no but thought I'd check/ask anyway...

Thanks,
randelld



Thanks for the reply but XML may not always be available on the remote
system so its not an option I can use - I am programming in PHP serverside
so it will be easier for me to have it (PHP) do the work for me.

randelld
Jul 20 '05 #5
N/A
so why are you poting in a javascript newsgroup? use php to do it....
"Randell D." <yo**************************@yahoo.com> wrote in message
news:x2***********************@news3.calgary.shaw. ca...

"N/A" <no*@here.com> wrote in message
news:jE****************@news-server.bigpond.net.au...
You can always create an XML HTTP request object (assuming the remote PC

has
MS XML installed) and use it to read in the contents of the remote page,
then parse it for the <TITLE> block...

"Randell D." <yo**************************@yahoo.com> wrote in message
news:AX***********************@news3.calgary.shaw. ca...

Folks,

I know javascript has no local or server based access to the disk

however
I
was wondering if one can read a remote page and take its html <TITLE>
value...

My guess is no but thought I'd check/ask anyway...

Thanks,
randelld



Thanks for the reply but XML may not always be available on the remote
system so its not an option I can use - I am programming in PHP serverside
so it will be easier for me to have it (PHP) do the work for me.

randelld

Jul 20 '05 #6

"N/A" <no*@here.com> wrote in message
news:GM*****************@news-server.bigpond.net.au...
so why are you poting in a javascript newsgroup? use php to do it....


My preference was for the client, not the server to perform the fetch...
Jul 20 '05 #7

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

Similar topics

13
by: Francesco Moi | last post by:
Hi. I would like to fetch a remote URL by using C and get its contents: myfile = get("http://www.foo.com/foo.html") Does exist any C library? Thank you very much.
4
by: Eric | last post by:
Hello, I am having some sort of security issue with my code. When I change a file's title in a Windows or console app, I have no problems. (I am using Microsoft's article & DsoFile.dll:...
7
by: Bernard Lebel | last post by:
Hello, I'm stumbled at a serious problem, and quite frankly getting desparate. This is a rather long-winded one so I'll try to get straight to the point. I have this Python program, that...
2
by: hazelnut2705 | last post by:
Hi there.. how to fetch data from database and then display in title bar? <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo...
1
by: rn5a | last post by:
I am using the Title property of the Page class in the Page_Load event to set the title of the page so that the browser displays appropriate titles. <html> <head runat="server"> <script...
2
by: sruthini | last post by:
Hi, I am doing send some values(signup form::firstname,lastname,title,organization) to mail id using javamail at the same time it should store in database, my problem is how to fetch values from...
20
by: sruthini | last post by:
Hi, I am doing send some values(signup form::firstname,lastname,title,organization) to mail id using javamail at the same time it should store in database, my problem is how to fetch values from...
0
by: Rilly | last post by:
Anyone use PowerMovielist here? I have the 0.14 beta version. Do you have a problem where some shows you search for cause the fetch to hang ? I'm pulling my hair out on this.. For example, I search...
10
dj12345
by: dj12345 | last post by:
Hi, (Asp.net + Ajax) I am creating a page which will fetch data from server without postbak of a page.. I have 2 controls on this page TextBox and Lable. I have assigned TextBoxWatermark...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...
0
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,...
0
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...
0
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...

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.