473,508 Members | 2,227 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing text string to a new window?

Would there ever be any problems with the following script depending
on what type of characters are in the text string? I am appending the
value of hidden form field to the query string.

//Assume JavaScript enabled browsers and popups allowed.
//Function to open the window
function openWin(elm){
var nHeight = 250;
var nWidth = 250;
var nXpos = (screen.availWidth - nWidth) / 2;
var nYpos = (screen.availHeight - nHeight) / 2;
var desc=document.myForm.elements[elm].value;
var statusPopup = window.open('description.htm?desc=' +
desc,'popupWin','top=' + nYpos + ',left=' + nXpos + ',screenY=' +
nYpos + ',screenX=' + nXpos + ',height=' + nHeight + ',width=' +
nWidth + 'location=no,menubar=no,resizable=no,scrollbars=no ,statusbar=no,toolbar=no');
}
<!-- Link example to call the function and hidden field -->
<a href="javascript:openWin('longdesc2')">Description </a>
<input type="hidden" name="longdesc2" value="This is some text of Joe
Cool's & Jane Doe's." />

The is the script in the new window.

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<script language="javascript" type="text/javascript">
var description=location.href.split('desc=');
if(description[1])
document.write(description[1].replace(/%20/g," "));
</script>
</body>
</html>
Jul 23 '05 #1
2 2194
In article <e5*************************@posting.google.com> ,
no********@msn.com enlightened us with...
Would there ever be any problems with the following script depending
on what type of characters are in the text string?


Yes. You have to URL encode any value you send IF you're forming the URL
yourself instead of using GET for a form.
The ampersand would be a very big problem. It's a field separator for form
values.

If you use a form and use GET, it automatically encodes the values and puts
them in the URL. I find this way to be the safest and easiest way to handle
querystring params with unknown values, myself.
You could just open a new window and set that as the target to a form and
submit the form onclick instead of what you're currently doing.

HTH

--
--
~kaeli~
To steal ideas from one person is plagiarism; to steal from
many is research.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2
Thanks for the insights.

John
Jul 23 '05 #3

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

Similar topics

0
1286
by: Steve Wark | last post by:
I'm trying to develop a lookup form in asp.net (vb), when a button is clicked a small search form will open in a second window which will display a list of values. When a value is selected the...
0
3824
by: nygiantswin2005 | last post by:
I am tring to write simple console application in C# to test the APIs functions made available by the dymo sdk. The dymo sdk provides a dll library that can be used to call functions that will...
7
2597
by: Wade Wegner | last post by:
Hello, I have been desperately trying to programmatically authenticate a windows user, create their credentials, and then redirect them to a different server while passing the credentials at the...
3
4052
by: Aaron | last post by:
I am having a little difficulty with a relatively simple task. I have a parent webform. I have a javascript attribute added to a button to open a new window when clicked. The user fills in a...
0
7401
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...
1
7063
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
7504
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...
1
5059
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
4720
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...
0
3211
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...
0
3196
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1568
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 ...
0
432
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...

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.