473,388 Members | 1,199 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,388 software developers and data experts.

How do I retrieve a URL into a variable?


I like to know if there is a JS function to retrieve a URL into a variable

cURL = somefunction("http://www.domain.com");

Is there something like this?

TIA,

Tom
Jul 23 '05 #1
11 15338
"Tom Szabo" <to*@intersoft.net.au> wrote in message
news:41********@dnews.tpgi.com.au...

I like to know if there is a JS function to retrieve a URL into a variable

cURL = somefunction("http://www.domain.com");

Is there something like this?

TIA,

Tom


By "retrieve a URL" do you mean of the page containing the JS?

<html>
<head>
<title>loc~href.htm</title>
<script type="text/javascript">
var url = document.location.href;
document.write(url);
</script>
</head>
<body>
</body>
</html>
Jul 23 '05 #2
On Wed, 17 Nov 2004 12:31:43 GMT, McKirahan wrote:
"Tom Szabo" <to*@intersoft.net.au> wrote in message
news:41********@dnews.tpgi.com.au...

I like to know if there is a JS function to retrieve a URL into a variable

cURL = somefunction("http://www.domain.com");
.... By "retrieve a URL" do you mean of the page containing the JS?


I suspect the OP is actually referring to retrieving the content
of another URL (than the page itself) into a JS var as text.

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
Jul 23 '05 #3
> By "retrieve a URL" do you mean of the page containing the JS?

I could be using the wrong terminology, what I ment is to get the content of
the web page the URL pointing to....so

var "url" would contain something like:

"<html>
<head>
.....

......
/html>"

Am I making sense? sorry if still not ....

TIA,

Tom

Jul 23 '05 #4
On Wed, 17 Nov 2004 22:34:50 +1000, Tom Szabo <to*@intersoft.net.au> wrote:

[snip]
I could be using the wrong terminology, what I ment is to get the
content of the web page the URL pointing to....so


Please read the FAQ (<URL:http://jibbering.com/faq/>). Your question is
answered there.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #5
> >> cURL = somefunction("http://www.domain.com");
...
By "retrieve a URL" do you mean of the page containing the JS?


I suspect the OP is actually referring to retrieving the content
of another URL (than the page itself) into a JS var as text.


YES, correct, that is what I like to do...
Jul 23 '05 #6

"Michael Winter" <M.******@blueyonder.co.invalid> wrote in message
news:opshl090olx13kvk@atlantis...
On Wed, 17 Nov 2004 22:34:50 +1000, Tom Szabo <to*@intersoft.net.au> wrote:
[snip]
I could be using the wrong terminology, what I ment is to get the
content of the web page the URL pointing to....so


Please read the FAQ (<URL:http://jibbering.com/faq/>). Your question is
answered there.


Thanks for that, but I think that asi a way too complicated solution....

If there is no simpler, I can just create a new window with the URL and read
the content of the DOC if nothing better, but I do beleive thre should be a
simpler solution...?

Thanks anyway,

Tom
Jul 23 '05 #7
Tom Szabo wrote:
By "retrieve a URL" do you mean of the page containing the JS?


I could be using the wrong terminology, what I ment is to get the
content of the web page the URL pointing to....so

var "url" would contain something like:

"<html>
<head>
....

.....
/html>"

Am I making sense? sorry if still not ....

TIA,

Tom


Use XmlHttpRequest object.

Berislav
Jul 23 '05 #8
"Tom Szabo" <to*@intersoft.net.au> wrote in message
news:41********@dnews.tpgi.com.au...
> cURL = somefunction("http://www.domain.com");

...
By "retrieve a URL" do you mean of the page containing the JS?


I suspect the OP is actually referring to retrieving the content
of another URL (than the page itself) into a JS var as text.


YES, correct, that is what I like to do...

Will this help? Watch for word-wrap.

Change the value of "onclick=XML()" as necessary.

<html>
<head>
<title>XMLHTTP.htm</title>
<script type="text/vbscript">
Sub XML(strURL)
Dim strXML
strXML = strURL
Dim objXML
Set objXML = CreateObject("Microsoft.XMLHTTP")
objXML.Open "GET", strURL, False
objXML.Send
If Err.Number = 0 And objXML.Status = 200 Then
strXML = objXML.ResponseText
strXML = Replace(strXML,"<","&lt;")
strXML = Replace(strXML,">","&gt;")
strXML = Replace(strXML,vbLf,"<br>")
End If
Set objXML = Nothing
document.write(strXML)
End Sub
</script>
</head>
<body>
<input type="button" value="Click Me!"
onclick="XML('http://www.Google.com/')">
</body>
</html>
Jul 23 '05 #9
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:ScKmd.98763$HA.57358@attbi_s01...
"Tom Szabo" <to*@intersoft.net.au> wrote in message
news:41********@dnews.tpgi.com.au...
>> cURL = somefunction("http://www.domain.com");
...
> By "retrieve a URL" do you mean of the page containing the JS?

I suspect the OP is actually referring to retrieving the content
of another URL (than the page itself) into a JS var as text.


YES, correct, that is what I like to do...

Will this help? Watch for word-wrap.

Change the value of "onclick=XML()" as necessary.


[snip]

You probably wanted the JavaScript version.

<html>
<head>
<title>Google.htm</title>
<script type="text/javascript">
function XML(strURL) {
var objXML = new ActiveXObject("Microsoft.XMLHTTP");
objXML.open("GET",strURL,false);
objXML.send();
var strXML = objXML.responseText;
strXML = strXML.replace(/</g,'&lt;');
strXML = strXML.replace(/>/g,'&gt;');
strXML = strXML.replace(/\n/g,'<br>');
document.write(strXML)
}
</script>
</head>
<body>
<input type="button" value="Click Me! (js)"
onclick="XML('http://www.Google.com/')">
</body>
</html>
Jul 23 '05 #10
You probably wanted the JavaScript version.

<html>
<head>
<title>Google.htm</title>
<script type="text/javascript">
function XML(strURL) {
var objXML = new ActiveXObject("Microsoft.XMLHTTP");
objXML.open("GET",strURL,false);
objXML.send();
var strXML = objXML.responseText;
strXML = strXML.replace(/</g,'&lt;');
strXML = strXML.replace(/>/g,'&gt;');
strXML = strXML.replace(/\n/g,'<br>');
document.write(strXML)
}
</script>
</head>
<body>
<input type="button" value="Click Me! (js)"
onclick="XML('http://www.Google.com/')">
</body>
</html>


Thanks, I will give it a go. Looks like this is is what I wanted,

Thanks again,

Tom
Jul 23 '05 #11
JRS: In article <ScKmd.98763$HA.57358@attbi_s01>, dated Wed, 17 Nov
2004 15:35:14, seen in news:comp.lang.javascript, McKirahan
<Ne**@McKirahan.com> posted :
"Tom Szabo" <to*@intersoft.net.au> wrote in message
news:41********@dnews.tpgi.com.au...
> >> cURL = somefunction("http://www.domain.com");
> ...
> > By "retrieve a URL" do you mean of the page containing the JS?
>
> I suspect the OP is actually referring to retrieving the content
> of another URL (than the page itself) into a JS var as text.
YES, correct, that is what I like to do...

Will this help? Watch for word-wrap.


Watching for word-wrap is the author's duty. Don't be slothful.

Change the value of "onclick=XML()" as necessary.

<html>
<head>
<title>XMLHTTP.htm</title>
<script type="text/vbscript">
Sub XML(strURL)
Dim strXML
strXML = strURL
Dim objXML
Set objXML = CreateObject("Microsoft.XMLHTTP")
...


Not only is this a javascript newsgroup, but it is also substantially a
group for web pages.

Therefore, since many differing OSs and browsers can be used to read Web
pages, a "solution" that works only with Microsoft systems is of limited
use, unless the OP has indicated otherwise. When a limited-use
"solution" is presented, a corresponding warning should be given. Yours
appears to be such a "solution", even in javascript.
--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "> " (SonOfRFC1036)
Jul 23 '05 #12

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

Similar topics

8
by: Tammy B. | last post by:
Hiya - Big puzzler for me. Code Below I create a class. I save it to a session variable. Then, I retrieve the session variable back into a new local variable. I am able to use a method which...
3
by: Ken Fine | last post by:
I have a Sub which defines a variable. I'm wondering if there's anyway I can get at that variable outside of the context of the Sub -- to pass the variable's contents to another page, for instance....
4
by: spiderman | last post by:
Hi, Is there a simple way to store session variable on the client-side javascript or retrieve the value of the session variable from the server-side session("variable") script onto the...
15
by: joun | last post by:
Hi all, i want to create in my asp.net application a custom server variable, so i can retrieve later in other pages (even asp or perl) with request.servervariables("HTTP_mycustomvariable") ...
41
by: Miguel Dias Moura | last post by:
Hello, I am working on an ASP.NET / VB page and I created a variable "query": Sub Page_Load(sender As Object, e As System.EventArgs) Dim query as String = String.Empty ... query =...
12
by: Phil Certain | last post by:
Hi, I'm trying to do something very simple...or at least it should be. I have created a host page (gen.aspx) and a very simple user control (us.ascx). The corresponding code-behind files are...
2
by: adam | last post by:
Hi ASP Expert, My goal is to retrieve my local machine's %USERNAME% environment variable from ASP page. When I enter http://RemoteServerName/testusername.asp?id=%USERNAME% directly into the IE...
2
by: Bishman | last post by:
Hi, I am retrieveing Application settings using "Properties.Settings.Default.xxxxxxxx" where xxxxxxxx is known at design time. How can I retrieve a 'soft' setting, ie: the value I wish to...
4
by: IRC | last post by:
hey, i am pretty new on javascript as well as PHP, Hey, anyone can you help me, how to pass the javascript array value to php page......... i want to retrieve the values which are arrayed on...
1
by: faultykid | last post by:
I would like to store a variable then call it back later. I have a variable on line 198 www = ''+this._ad.clickUrl+''; and on line 321 i try document.write(www);
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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,...
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...

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.