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

variable in window.open function

Can anyone help with my javascript code please?

I have a button which when pressed calls a function named 'popjack'
which pops up a new browser window. The function is called with a
paramter 'printflag' and I want to assign the value of this to a
variable 'var1' in the url of the browser window to be opened.

Here is my code below, but 'var1=' part is wrong, can anyone help
please. Many thanks.

Rob.

<script language="JavaScript">

function popjack(printflag){

window.open('myfile.php?var1=printflag','popjack1' ,
'toolbar=no,location=no,width=650,height=534');
}

</script>

<button class=button onClick="javascript: popjack(1)"> Print
Waybill</button>

Jul 23 '05 #1
3 1813
Lee
ro******@hotmail.com said:

Can anyone help with my javascript code please?

I have a button which when pressed calls a function named 'popjack'
which pops up a new browser window. The function is called with a
paramter 'printflag' and I want to assign the value of this to a
variable 'var1' in the url of the browser window to be opened.

Here is my code below, but 'var1=' part is wrong, can anyone help
please. Many thanks.

Rob.

<script language="JavaScript">

function popjack(printflag){

window.open('myfile.php?var1=printflag','popjack1 ',
'toolbar=no,location=no,width=650,height=534');


window.open('myfile.php?var1='+printflag,'popjack1 ',
'width=650,height=534,resizeable');

toolbar and location are "no" by default if you specify
any attributes. Popups shold always be resizable because
you don't know what the user might have done with font size.

Jul 23 '05 #2
Lee <RE**************@cox.net> writes:
window.open('myfile.php?var1='+printflag,'popjack1 ',
'width=650,height=534,resizeable');
This works if the string passed as "printflag" contains only
characters valid in a URL. Otherwise, it would be safest
to escape the string. For a URL simulating a GET request,
that means using the "escape" function, and also turning
spaces into plusses (that's what posting a form would do):

printflag = escape(printflag).replace(/[ ]/g,"+");
toolbar and location are "no" by default if you specify
any attributes. Popups shold always be resizable because
you don't know what the user might have done with font size.


Hear, hear!
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #3
Lasse Reichstein Nielsen wrote:
Lee <RE**************@cox.net> writes:
window.open('myfile.php?var1='+printflag,'popjack1 ',
'width=650,height=534,resizeable');


This works if the string passed as "printflag" contains only
characters valid in a URL. Otherwise, it would be safest
to escape the string. For a URL simulating a GET request,
that means using the "escape" function, and also turning
spaces into plusses (that's what posting a form would do):

printflag = escape(printflag).replace(/[ ]/g,"+");


This will not work as supposed, as the spaces are already
converted to `%20' by escape(). The following should work:

printflag = escape(printflag).replace(/%20/g,"+");

Or consider this:

printflag = escape(printflag.replace(/ /g, "+"));

I also wonder why you used a character class only for a
space character.
PointedEars
Jul 23 '05 #4

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

Similar topics

9
by: Bryan Ashby | last post by:
All, I'm looking for a way to define a "dummy" variable in JavaScript; specifically for the window object. I would like to define a window object that would normally be generated with...
2
by: umashd | last post by:
Hi, I am doing a web based project for my graduation. I studied bit of java for backend processesing and javascript for the client. Here is the scenario. In the FORM, I use INPUT TYPE=text...
8
by: nescio | last post by:
hello, i have got a javascript that opens a new window. when i call the javascript function i want to ad a variable. what you see on the pop up depends on the variable. but the variable in...
2
by: Joe Molloy | last post by:
Hi, This isn't a mission critical question but I thought I'dl throw it out there for your feedback as it's a bit curious. I have developed a shopping cart for an application I'm working on...
6
by: paul | last post by:
HI! How do we send a variable from an Iframe page back to its parent? I have a script that calculates the iframe's window size but I need to know how to send that value back to its parent so I...
6
by: ntdude4 | last post by:
I am trying to make a variable link on a page. The page has a text box for a stock symbol. The code is: <input type=TEXTBOX Name="symtb" value="" size="10> The value of the text box {the stock...
5
by: rockdale | last post by:
Hi, all: I have a linkbutton and I use javascript to open another webpage in a new window. I also want to set my session variable value when this linkbutton get clicked. These session variable...
3
by: Skip | last post by:
OK, I'm a novice in JS but have lots of coding experience. I am trying to accomplish something that would seem somewhat simple - BUT IT'S NOT. I have a basic window that calls another window...
1
pbmods
by: pbmods | last post by:
VARIABLE SCOPE IN JAVASCRIPT LEVEL: BEGINNER/INTERMEDIATE (INTERMEDIATE STUFF IN ) PREREQS: VARIABLES First off, what the heck is 'scope' (the kind that doesn't help kill the germs that cause...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.