473,626 Members | 3,389 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I read args passed in address bar?


Folks,

I'm pretty sure it can be done, and I'm doing pretty good with my
javascript so I'm pretty sure I just need a quick point in the right
direction...

If my web page is referenced in the address bar, how can I read these
arguements?

Thus, with

http://www.mydomain.com/mypage.html?abc=123

Is there an easy method to read abc=123 ?

Why?

I want to create a single HTML file that contains a script that will be
used to display an image in the center of the screen. This HTML file
will be used as a popup so when a user clicks on a thumbnail, the larger
image opens... I don't like the idea of having numerous html files
containing reference to each image - I'd prefer to have my parent window
call the popup and pass it arguements, like the filename and size of
the image - One advantage to this method is that I can tailor the size
of the popup window to the size of the image.

Before anybody beats me over the head for using a popup, I
1) am working on an application, not a website
2) my end users will have javascript and popups enabled
3) popups open only with an onClick event occurs on a correctly labeled
link.

All help, via the newsgroup, much appreciated... thanks,
randelld
Jul 23 '05 #1
2 3288
If my web page is referenced in the address bar, how can I read these
arguements?

Thus, with

http://www.mydomain.com/mypage.html?abc=123

Is there an easy method to read abc=123 ?


You need to look in: location.search
You may want to escape the passed data. This is commonly done.

This html file and associated Javascript passed data to a second htmls
file:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Loops</TITLE>

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">

<SCRIPT type="text/javascript">

function foo()
{
var theData, newWindow, URLstring;

// Pass this data. I believe the data is limitted to a max
// of 2k.
theData = "?data=" + escape("see if the caller gets this.");
URLstring = "tryRead.ht ml" + theData;
newWindow = window.open(URL string,"Printab le",
"statusbar,menu bar,resizable,t oolbar,height=6 00,width=800");
newWindow.focus ();
}

</script>

</HEAD>
<BODY onload='
alert("before." );
foo();
alert("after.") ;'>

<br><br>Lets open a window and pass data to the window.

</BODY>

</HTML>
This html file and Javascript read the passed data:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Read passed data</TITLE>

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<SCRIPT type="text/javascript">

function foo2()
{
var theData;
var begin;

begin = location.search .indexOf("data= ");
if (begin >0 )
{

theData = location.search .substring(begi n+5,location.se arch.length);
theData = unescape(theDat a);
alert("theData = " + theData);
}
}
</script>

</HEAD>
<BODY onload="foo2()" >

<br><br>Read passed data.

</BODY>

</HTML>

Robert
Jul 23 '05 #2
Robert wrote:
If my web page is referenced in the address bar, how can I read these
arguements?

Thus, with

http://www.mydomain.com/mypage.html?abc=123

Is there an easy method to read abc=123 ?

You need to look in: location.search
You may want to escape the passed data. This is commonly done.

This html file and associated Javascript passed data to a second htmls
file:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Loops</TITLE>

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">

<SCRIPT type="text/javascript">

function foo()
{
var theData, newWindow, URLstring;

// Pass this data. I believe the data is limitted to a max
// of 2k.
theData = "?data=" + escape("see if the caller gets this.");
URLstring = "tryRead.ht ml" + theData;
newWindow = window.open(URL string,"Printab le",
"statusbar,menu bar,resizable,t oolbar,height=6 00,width=800");
newWindow.focus ();
}

</script>

</HEAD>
<BODY onload='
alert("before." );
foo();
alert("after.") ;'>

<br><br>Lets open a window and pass data to the window.

</BODY>

</HTML>
This html file and Javascript read the passed data:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Read passed data</TITLE>

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<SCRIPT type="text/javascript">

function foo2()
{
var theData;
var begin;

begin = location.search .indexOf("data= ");
if (begin >0 )
{

theData = location.search .substring(begi n+5,location.se arch.length);
theData = unescape(theDat a);
alert("theData = " + theData);
}
}
</script>

</HEAD>
<BODY onload="foo2()" >

<br><br>Read passed data.

</BODY>

</HTML>

Robert


Thanks - I think I can run with that... Much appreciated,
randelld
Jul 23 '05 #3

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

Similar topics

12
8778
by: Chuck Anderson | last post by:
Can anyone point me in the right direction? I want to use Php to automate confirmation of someone joining an email list by them replying to an email (so they don't have to have a browser?). I will probably use a hyperlink with a unique ID, but I also want to know how to go about reading from a mailbox with Php so I can use an email reply method, too. I'm having trouble finding any kind of tutorial. From the bit of searching I've done,...
2
2740
by: Pierre Fortin | last post by:
This quest for understanding started very innocently... A simple error on my part, passing on args as "args" instead of "*args" to os.path.join() led me to wonder why an error wasn't raised... def foo(*args): ... return os.path.join(*args) foo('a','b') # returns 'a/b'
20
1794
by: ncf | last post by:
Hello all, I was wondering if there was any way to pass arguments (integer and such) by reference (address of), rather than by value. Many thanks in advance. -Wes
4
2411
by: Bill Cohagan | last post by:
I'm writing a console app in c# and am encountering a strange problem. I'm trying to use redirection of the standard input stream to read input from a (xml) file. The following code snippet is from this app: =============================== static void Main(string args) { if (args.Length > 0) Console.SetIn(new StreamReader(args)); //executes if I don't use the "<", ">" redirection syntax when invoking XmlTextReader xmlin = new...
2
22782
by: hvaisane | last post by:
Valgrind says ==11604== Invalid read of size 4 ==11604== at 0x8048ABB: main (foo.cc:36) ==11604== Address 0x1B92415C is 4 bytes inside a block of size 8 free'd ==11604== at 0x1B90514F: operator delete(void*) (vg_replace_malloc.c:156) ==11604== by 0x804A1BA: __gnu_cxx::new_allocator<Foo>::deallocate(Foo*, unsigned) (new_allocator.h:86) ==11604== by 0x8049C08: std::_Vector_base<Foo, std::allocator<Foo> >::_M_deallocate(Foo*,...
19
2070
by: Mark Richards | last post by:
I've been programming for many years, but have only recently taken a deep "C" dive (bad pun, i know) and need a lot of explanation from an expert. My questions center around those mysterious pointer beasties. The following code is excerpted from digitemp, a program that reads 1-wire devices. Digitemp is the work of Brian C. Lane. As I walk through this code, I have a number of questions. I'm hoping someone with experience in...
3
5044
by: RSB | last post by:
Hi Everyone, I have this TextBox with the TextMode="MultiLine". so now it does not validate the text in the TextBox for the MaxLength SO i have decided to execute a CustomValidator for this Textbox and run a CLientSideFunction. now i was making this clientsidefunction generic so that i can validate all the other textboxes also. Now to do this i need the access to the MaxLength Property, which i am not able to read in the Java...
1
2058
by: jakebbohio | last post by:
I have a user-defined XPath function implemented using a custom context and the IXsltContextFunction interface. For its arguments, it accepts 3: { XPathResultType.Any, XPathResultType.Any, XPathResultType.String }. The function is called datediff, which converts the arguments to DateTimes, and gives args - args in the units specified by args (e.g., "days", "months"). Anyhow, as an example, Let's say I have the following XML file: ...
1
1003
by: cmdolcet69 | last post by:
So I have two handlers: AddHandler dataBackgroundWorker.DoWork, AddressOf DoDualDSIWorkCOM1 AddHandler dataBackgroundWorker2.DoWork, AddressOf DoDualDSIWorkCOM1 dataBackgroundWorker.RunWorkerAsync(New Object() {currentSerial}) dataBackgroundWorker2.RunWorkerAsync(New Object() {currentSerial2}) when I look in the sub DoDualDSIWorkCOM1 I only see the first COM Port being passed in the event args
0
8268
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
8202
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
8707
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
8641
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
7199
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...
0
5575
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
4093
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...
1
2628
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
2
1512
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.