473,606 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Pass Parameters to Java Script?

Anyone understand how to pass parameters to a JavaScript. If anyone finds
this easy to do maybe they could take a look at my short script on this page
and show me how it needs to be changed.

http://franz.org/java.htm

Thanks for any help.
Jul 20 '05 #1
13 26980
Hi,

Al Franz wrote:
Anyone understand how to pass parameters to a JavaScript. If anyone finds
this easy to do maybe they could take a look at my short script on this page
and show me how it needs to be changed.

http://franz.org/java.htm

Thanks for any help.


The page doesn't work.

I assume that you are talking about passing parameters from Java to
JavaScript, since you post in comp.lang.java. javascript. If it is so,
then you should check
http://www.galasoft-LB.ch/myjavascri...LiveConnect102

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
Actually what I want to do is pass parameters from my HTML code to the
JavaScript. Not sure why the web page does not work for you, are others
having problems? Maybe it had a hiccup?
Jul 20 '05 #3

"Al Franz" <al****@netmati on.com> wrote in message
news:IzVZa.1237 01$YN5.85449@sc crnsc01...
Anyone understand how to pass parameters to a JavaScript. If anyone finds
this easy to do maybe they could take a look at my short script on this page and show me how it needs to be changed.

http://franz.org/java.htm

Thanks for any help.


Add additional parameters to the function call:
<A HREF="javascrip t:launch('photo/2003047.jpg', 500, 300)">

Then, in your function:
function launch(url, wdth, hght) {
remote =
open(url,'','re sizable=yes,scr ollbars=yes,too lbar=no,locatio n=no,directorie s
=no,status=no,m enubar=no,copyh istory=no,width =wdth,height=hg ht');
}

No difference between passing 1 (url) and 3 (url, height, width)-- pass more
if you like.

HTH
Jul 20 '05 #4
Hi,

Mark wrote:
"Al Franz" <al****@netmati on.com> wrote in message
news:IzVZa.1237 01$YN5.85449@sc crnsc01...
Anyone understand how to pass parameters to a JavaScript. If anyone finds
this easy to do maybe they could take a look at my short script on this


page
and show me how it needs to be changed.

http://franz.org/java.htm

Thanks for any help.

Add additional parameters to the function call:
<A HREF="javascrip t:launch('photo/2003047.jpg', 500, 300)">

Then, in your function:
function launch(url, wdth, hght) {
remote =
open(url,'','re sizable=yes,scr ollbars=yes,too lbar=no,locatio n=no,directorie s
=no,status=no,m enubar=no,copyh istory=no,width =wdth,height=hg ht');
}

No difference between passing 1 (url) and 3 (url, height, width)-- pass more
if you like.

HTH


For various reasons (see the FAQ of comp.lang.javas cript), you should
never use the pseudo-protocol "javascript :".

The best way is to use the ONCLICK event handler, and to use the SRC
attribute to specify an action which will be executed only if JavaScript
is not enabled (if you return false in the ONCLICK event handler).

Example:

<A HREF="nojs.html "
ONCLICK="myMeth od();return false;">
Text</A>

nojs.html being a page handling the case where the user doesn't have
JavaScript.

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 #5
Actually, the script you propose doesn't work. See correction under.

Mark wrote:
"Al Franz" <al****@netmati on.com> wrote in message
news:IzVZa.1237 01$YN5.85449@sc crnsc01...
Anyone understand how to pass parameters to a JavaScript. If anyone finds
this easy to do maybe they could take a look at my short script on this


page
and show me how it needs to be changed.

http://franz.org/java.htm

Thanks for any help.

Add additional parameters to the function call:
<A HREF="javascrip t:launch('photo/2003047.jpg', 500, 300)">

Then, in your function:


Should be:

function launch( url, wdth, hght )
{
remote = open( url, "WindowName ",
'resizable,scro llbars,width='
+ wdth + ',height=' + hght );
}

What I did is

1) Give a name to the window. A window should always have a unique name,
to avoid nasty side effects.

2) Remove all the parameters which are set to "no" in the open method.
Parameters are set to "no" per default. It's not wrong to mention them,
but it's not useful.

3) wdth and hght are parameters, thus the string should be constructed
using the concatenation operator '+'.

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 #6
Laurent,

Thank you very much, it is looking better but have a few follow up
questions. I implemented what you said at, even though I kept 2 "no"
parameters in there in case I change those....

http://franz.org/java.htm

1. Can I put the WindowName as a parameter in the HTML, since currently I
have to close a popup before opening a new one since the old parameters will
stick. Should it be in quotes in my HTML, and setup the same as wdth and
hght ?

2. Any way to set a background color for the frame in the window that pops
up?

3. Finnaly the wdth and hght I used as a parameter is the actual photo width
+ 20 pixels and the actual photo height + 30 pixels. Would it be possible
to hard code the 20 and 30 in the script so I could put the actual photo
dimensions in the HTML code parameters.

Thanks again, any help with me finishing up these mods would be great.

--Al
Jul 20 '05 #7

[Original message clipped for brevity]

http://franz.org/java.htm

1. Can I put the WindowName as a parameter in the HTML, since currently I
have to close a popup before opening a new one since the old parameters will stick. Should it be in quotes in my HTML, and setup the same as wdth and
hght ?
Yes, I mentioned you may pass the function any reasonable number of
arguements. Window name would be an arguement. Use it as you would any
other-- string arguements are passed in quotes, but do not quote the dummy
variable.

2. Any way to set a background color for the frame in the window that pops
up?
Hmmm... Not sure on this one. I suspect not-- as you are not actually
opening a document, but rather only an image. if your 'url' was an HTML
document, you could set the background color as in any other document.
Perhaps someone else will know better, or perhaps changing the 'url'
variable to an actual page containing the image is the only way.

3. Finnaly the wdth and hght I used as a parameter is the actual photo width + 20 pixels and the actual photo height + 30 pixels. Would it be possible
to hard code the 20 and 30 in the script so I could put the actual photo
dimensions in the HTML code parameters.

Yes. In the opener function add +20 and +30 to the variables describing
height and width.

Thanks again, any help with me finishing up these mods would be great.

--Al
Also, my thanks to Laurent Bugnion for 'fleshing out' my answers-- and my
understanding.

Mark

Jul 20 '05 #8
Tried adding that 20 and 30 every which way I could, but doesn't seem to
work. What is wrong with this format???
<SCRIPT language=javasc ript>
function launch4( url, wdth, hght)
{
remote = open( url, "WindowName ",
'resizeable=no, scrollbars=no,w idth='
+ wdth+20 + ',height='+ hght+30 );
}
</SCRIPT>
"Mark" <no**@given.com > wrote in message
news:y5******** ***********@rwc rnsc52.ops.asp. att.net...

[Original message clipped for brevity]

http://franz.org/java.htm

1. Can I put the WindowName as a parameter in the HTML, since currently I have to close a popup before opening a new one since the old parameters

will
stick. Should it be in quotes in my HTML, and setup the same as wdth and hght ?


Yes, I mentioned you may pass the function any reasonable number of
arguements. Window name would be an arguement. Use it as you would any
other-- string arguements are passed in quotes, but do not quote the dummy
variable.

2. Any way to set a background color for the frame in the window that pops up?


Hmmm... Not sure on this one. I suspect not-- as you are not actually
opening a document, but rather only an image. if your 'url' was an HTML
document, you could set the background color as in any other document.
Perhaps someone else will know better, or perhaps changing the 'url'
variable to an actual page containing the image is the only way.

3. Finnaly the wdth and hght I used as a parameter is the actual photo

width
+ 20 pixels and the actual photo height + 30 pixels. Would it be possible to hard code the 20 and 30 in the script so I could put the actual photo
dimensions in the HTML code parameters.


Yes. In the opener function add +20 and +30 to the variables describing
height and width.

Thanks again, any help with me finishing up these mods would be great.

--Al


Also, my thanks to Laurent Bugnion for 'fleshing out' my answers-- and my
understanding.

Mark


Jul 20 '05 #9

"Laurent Bugnion, GalaSoft" <galasoft-LB@bluewin_NO_S PAM.ch> wrote in
message news:3F391B7F.3 030106@bluewin_ NO_SPAM.ch...

For various reasons (see the FAQ of comp.lang.javas cript), you should
never use the pseudo-protocol "javascript :".


Is anyone imagined to be able to find anything in this "FAQ"? At
www.faqs.org is a "meta-FAQ" that points to a supposed "FAQ" at
http://developer.irt.org/script/script.htm -- but go ahead and try to figure
out where any information is located there about the pseudo-protocol
"javascript :".

Anyway, I've never come across this admonition, and I don't know why not to
use "javascript :". Several years of experience with it has turned up no
direct evidence of a problem. Can you fill us in?

Jul 20 '05 #10

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

Similar topics

3
3913
by: Don | last post by:
How does one pass parameters to a php script when it's invoked via <a href=...> tag? Is there some way for the php script to pick up URL parameters passed via the <a href...> tag? I know how to do it via a POST, but obviousy this is not a POST. Thanks, Don ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups ----= East and...
0
1873
by: Scott Townsend | last post by:
I'd like to pass parameters to a local Application from a webpage. something like: <a href="file:///C:/Program%20Files/myapp/myapp.exe%20-custno:mycustno%20-quote no:12345%20-item:12345">test with params</a></p> Though it does not like it. If I leave off the Parameters it works fine.
3
32136
by: DCB | last post by:
Hello. I have an easy question, likely, that has me in a headspin. I have an include file to a frames based site that basically forces frames on the end user if they visit the site and hit a non-frames created page... Simply, it is: if (parent != self)
7
21605
by: Zlatko Matiæ | last post by:
Let's assume that we have a database on some SQL server (let it be MS SQL Server) and that we want to execute some parameterized query as a pass.through query. How can we pass parameters to the server ? Is it possible to use parameters in pass-through queries ? An additional question: Is it possible to connect to a database on MySQL or PostgreSQL using ADO ? Is it possible to execute pass-through queries with parameters, using ADO...
1
2900
by: menmysql | last post by:
hi to all, in my jsp page hyper links are there starting from "A" to "Z". when ever i click on any one of those links it should call itself and pass a parameter of its value. for example if i click on "A" same page should display once again with a parameter "A". how to do it. i am also sending some code also <%@ page import="java.sql.*;"%> <%@ page session="true"%> <%!String un,per=null;%>
10
13637
by: Robert Dailey | last post by:
Hi, I noticed in Python all function parameters seem to be passed by reference. This means that when I modify the value of a variable of a function, the value of the variable externally from the function is also modified. Sometimes I wish to work with "copies", in that when I pass in an integer variable into a function, I want the function to be modifying a COPY, not the reference. Is this possible?
1
1457
by: ScripterSam | last post by:
How do I pass parameters to a java script function? The parmeter will contain space in its value Please help...
1
2976
by: pladdypants | last post by:
Hey there, I originally posted on the PHP forum and was told by a moderator that my Apache setup seems to be off. The problem is I can run a simple php script in my cgi-bin, however it doesn't pass any parameters. The goal of the script is to show a form, get the users name, and then call the script again and print "Hello, $_GET". When a name is entered though, the script is called with no parameter passed, and the $_GET array is empty. ...
1
2559
by: kkshansid | last post by:
i want to pass both variables($q1 and value of select) from this php page to java script so that i can get both variables in second php file srt.php <script type="text/javascript" src="st.js"></script> <?php $q1=$_GET; require("conn.php"); $sql="SELECT distinct(".$q1.")FROM inst";
0
7939
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
8432
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
8299
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
6753
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
5962
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
5456
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
3919
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
2442
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
1
1548
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.