473,654 Members | 3,190 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.availWi dth - nWidth) / 2;
var nYpos = (screen.availHe ight - nHeight) / 2;
var desc=document.m yForm.elements[elm].value;
var statusPopup = window.open('de scription.htm?d esc=' +
desc,'popupWin' ,'top=' + nYpos + ',left=' + nXpos + ',screenY=' +
nYpos + ',screenX=' + nXpos + ',height=' + nHeight + ',width=' +
nWidth + 'location=no,me nubar=no,resiza ble=no,scrollba rs=no,statusbar =no,toolbar=no' );
}
<!-- Link example to call the function and hidden field -->
<a href="javascrip t:openWin('long desc2')">Descri ption</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>Untitl ed Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>

<body bgcolor="#FFFFF F" text="#000000">
<script language="javas cript" type="text/javascript">
var description=loc ation.href.spli t('desc=');
if(description[1])
document.write( description[1].replace(/%20/g," "));
</script>
</body>
</html>
Jul 23 '05 #1
2 2200
In article <e5************ *************@p osting.google.c om>,
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
1298
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 clicking oF a button on this form will close the window and return the value to the original form. I've used VS2003 to create an ASP.NET application into which I added webform1.aspx & webform2.aspx, the code behind these forms is below; The...
0
3834
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 print labels on the DYMO LabelWriter printer. Here is my C# code. Please let what am I doing wrong. This code is successfully compiled, but it does not work when you execute the final executable program. I have included the c structure and...
7
2610
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 same time so that they don't have to login again. Specifically, I have two webservers in the same domain. When I have a user go to Webserver A (which uses basic authentication) I programmatically create either a user credential or impersonate...
3
4061
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 textbox then clicks the button and on page load the child window should grab that val run a query an present the results. Given that I am bouncing between server side controls and client script. I am just having a little trouble passing my textbox...
0
8379
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
8294
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
8816
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
8709
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...
1
8494
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7309
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
4297
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1924
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1597
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.