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

Problem with document.write and amperands

At my company, we have a javascript function that uses document.write()
calls to create an INPUT tag with type set to "image". The image that
it is downloading comes from a dynamic image server, so it has lots of
stuff in the query string, including ampersands. The image that I'm
getting in my web page as a result of this call is not configured
correctly. After some investigation, I've found that the
document.write() call seems to be encoding the & into its entity
reference, an amperand followed by amp;. Normally, this would be
desired, but in this case, I actually need an ampersand.

For complicated reasons, I may not be able to change the function
itself, so I tried to modify the DOM structure itself with the
following code:

rExp = /&/gi;
newString = new String(buttons[index].src);
newString.replace(rExp, "&");
buttons[index].src = newString;
alert(buttons[index].src);
The message of the alert shows a changed URL - the amp; is gone.
However, the image itself doesnt change. I get similar results in
current versions of IE and Netscape. It appears that changing the
source attribute of an input object doesn't cause a reload of the image
itself, like it would for an image object.

Any suggestions?

Jul 24 '05 #1
2 2048
"Monte Gardner" <Mo***********@asu.edu> wrote:
At my company, we have a javascript function that uses
document.write() calls to create an INPUT tag with type set to
"image".
Using image submit buttons is usually a bad idea. It means trying hard
to avoid the simple and robust and useable way, for the sake of assumed
esthetics. (Besides, for some odd reason, almost all image submit
buttons are somewhere between ugly and very ugly.)
The image that it is downloading comes from a dynamic
image server, so it has lots of stuff in the query string,
including ampersands.
That's getting rather absurd. Or is this a one in a million case where
it makes sense to generate the image dynamically? A real map, so that
clicking on it also means selecting a location? And a dynamically
generated map at that?
The image that I'm getting in my web page as
a result of this call is not configured correctly.
I'm not surprised.
After some
investigation, I've found that the document.write() call seems to
be encoding the & into its entity reference, an amperand followed
by amp;.
What makes you think so?
Normally, this would be desired, but in this case, I
actually need an ampersand.
Using &amp; _is_ the way (well, a way; you could use & too) of
getting an ampersand in HTML.
For complicated reasons, I may not be able to change the function
itself, so I tried to modify the DOM structure itself


Stop digging deeper. Climb up.

What is the original problem? What is the URL?

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 24 '05 #2
Monte Gardner wrote:
At my company, we have a javascript function that uses document.write() calls to create an INPUT tag with type set to "image". The image that it is downloading comes from a dynamic image server, so it has lots of stuff in the query string, including ampersands.
[snip]
After some investigation, I've found that the
document.write() call seems to be encoding the & into its entity
reference, an amperand followed by amp;. Normally, this would be
desired, but in this case, I actually need an ampersand.


Correct me if I'm wrong, but surely ampersands in URLs *should* be
escaped as &amp;? (Remember all the confusion caused in old versions of
Netscape when people used things like manual.php?page=1&section=8 -
Netscape interpreted &sect as &sect;.)

--
Safalra (Stephen Morley)
http://www.safalra.com/hypertext/

Jul 24 '05 #3

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

Similar topics

1
by: Lizzy | last post by:
I have an internet application which has a progress bar show whenever the customer is requesting data from the server. This progress bar is coded to work in both Netscape 4.75 and above and IE 5.0...
4
by: JesusFreak | last post by:
From: us_traveller@yahoo.com (JesusFreak) Newsgroups: microsoft.public.scripting.jscript Subject: toolbar script problem NNTP-Posting-Host: 192.92.126.136 Recently, I downloaded the following...
2
by: darren | last post by:
I have a small Javascript problem with that mutch love web browser safari, I tested the code on all other browsers PC (Win) and Linux and IE on the mac and it seams to work ok, but for some reason...
5
by: althafexcel | last post by:
hi everyone Im trying to include an external js in my aspx page under the head tag, it doesn't load or it displays an object expected error whenver the function from the .js is called. Actually...
1
by: mostafahamdyfcis | last post by:
Hello all I have used the sample code which exist in the following URL: http://www.eggheadcafe.com/articles/javascript_modal_dialog.asp which create modal dialog box, but some problem...
5
by: mukeshrasm | last post by:
hello friends I am new to javascript and I have a problem. I am giving the code <!-- Paste this code into the CSS section of your HTML document --> <html> <head> <style type="text/css">...
5
by: thallasridevi | last post by:
Hello, I am trying to get system information. I found a script. When i tried it, it is working in internet explorer. But it is not working with mozilla. I think problem is with below statement as...
2
by: davidson1 | last post by:
Hai friends..for menu to use in my website..i found in one website....pl look below website.... http://www.dynamicdrive.com/dynamicindex1/omnislide/index.htm i downloaded 2 files.... ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
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...
0
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
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,...

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.