Hope someone can help .....
Have a function which creates a HTML HREF
function fLink(aText)
{ return '<a href=javascript :DoLinkSearch(" '+aText+'")>'+a Text+'</a>'; }
If the parameter value is "simple" (no spaces), then the function returns
the HTML as expected
However, if the value does contain spaces, the HTML returned is cut off at
the first space
eg
called with FRED returns
javascript:DoLi nkSearch("FRED" )>FRED</a>'
called with FRED SMITH returns javascript:DoLi nkSearch("FRED
which is invalid HTML
Can anyone explain what is happening and how I "fix" the problem
Thanks,
Brian 3 1704
"Brian" <br**********@e sc.vic.gov.au> wrote in message
news:dr******** ***@otis.netspa ce.net.au... Hope someone can help .....
Have a function which creates a HTML HREF
function fLink(aText) { return '<a href=javascript :DoLinkSearch(" '+aText+'")>'+a Text+'</a>'; } If the parameter value is "simple" (no spaces), then the function returns the HTML as expected
However, if the value does contain spaces, the HTML returned is cut off at the first space
eg
called with FRED returns javascript:DoLi nkSearch("FRED" )>FRED</a>'
called with FRED SMITH returns
javascript:DoLi nkSearch("FRED which is invalid HTML
Can anyone explain what is happening and how I "fix" the problem
Thanks,
Brian
Use escape() as in:
function fLink(aText) {
return '<a
href=javascript :DoLinkSearch(" '+escape(aText) +'")>'+aText+ '</a>';
}
Brian wrote: Hope someone can help .....
Have a function which creates a HTML HREF
function fLink(aText) { return '<a href=javascript :DoLinkSearch(" '+aText+'")>'+a Text+'</a>'; } If the parameter value is "simple" (no spaces), then the function returns the HTML as expected
However, if the value does contain spaces, the HTML returned is cut off at the first space
eg
called with FRED returns javascript:DoLi nkSearch("FRED" )>FRED</a>'
called with FRED SMITH returns javascript:DoLi nkSearch("FRED
which is invalid HTML
The function will always return invalid HTML regardless of what
parameter you pass it. Error correction by the browser means that
sometimes it works if it's not too broken. Introducing spaces into the
parameter takes it beyond the error correction capabilities of most
browsers and you see the brokenness.
Attribute values (in this case the value of the A element's href
attribute) should be enclosed in quotes:
"In certain cases, authors may specify the value of an attribute
without any quotation marks. The attribute value may only contain
letters (a-z and A-Z), digits (0-9), hyphens (ASCII decimal 45),
periods (ASCII decimal 46), underscores (ASCII decimal 95), and
colons (ASCII decimal 58). We recommend using quotation marks even
when it is possible to eliminate them."
<URL:http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.2>
In the example, the inclusion of brackets () and quotes in the attribute
value means that it must have quotes. Single and double quotes have to
be properly nested and quoted:
return '<a href="javascrip t:DoLinkSearch( \''
+ aText + '\');">' + aText + '</a>';
Which gets really messy - why not use DOM (see below)?
Can anyone explain what is happening and how I "fix" the problem
Explanation above, the suggested 'fix' is just a bandaid.
Using script in the href attribute leads to mysterious behaviour for
some users so put something valid in the href and the script into an
onclick attribute that returns false to stop navigation.
The following will return an A element ready for insertion to your
document based on the same call you have now:
function fLink(aText)
{
var oA;
if (document.creat eElement && document.create TextNode){
oA = document.create Element('a');
oA.onclick = function (){
DoLinkSearch(aT ext);
return false;
}
oA.href = '#';
oA.appendChild( document.create TextNode(aText) );
}
return oA;
}
In the calling function, make sure an element is returned and if so,
append it somewhere in the document.
--
Rob
On 2006-02-03, Brian <br**********@e sc.vic.gov.au> wrote: Hope someone can help .....
Have a function which creates a HTML HREF
function fLink(aText) { return '<a href=javascript :DoLinkSearch(" '+aText+'")>'+a Text+'</a>'; } If the parameter value is "simple" (no spaces), then the function returns the HTML as expected
However, if the value does contain spaces, the HTML returned is cut off at the first space
eg
called with FRED returns javascript:DoLi nkSearch("FRED" )>FRED</a>'
called with FRED SMITH returns javascript:DoLi nkSearch("FRED
which is invalid HTML
both examples are invalid HTML.
Can anyone explain what is happening and how I "fix" the problem
html needs "these quottes" around the whole href value.
also </ in a string is invalid javascript.
function fLink(aText)
{ return '<a href="javascrip t:DoLinkSearch( \''+aText+'\')" >'+aText+'<\/a>'; }
--
Bye.
Jasen This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Daryl |
last post by:
Hello
I am using apply-templates and would like to pass a parameter to the
template using with-param. Using call-template passes the parameter,
but when I use apply-templates, the parameter seems to be lost. Can
parameters be passed with apply-templates? Any ideas?
<!--xml-->
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="tran2.xsl"?>
<doc>
|
by: Keith Chadwick |
last post by:
I have a fairly hefty XSLT file that for the sake of debugging and clarity I
wish to split into some separate sub-templates contained within the same
file. The master template calls an apply-templates and passes a node set to
it. This template in turn defines approximately 15 variables that dictate
how the following template should proceed. Pseudo example:
<!-- Root transformation called via .NET XSLTransform()-->
<xsl:template...
|
by: Harolds |
last post by:
The code below worked in VS 2003 & dotnet framework 1.1 but now in VS 2005
the pmID is evaluated to "" instead of what the value is set to:
....
xmlItems.Document = pmXML
// Add the pmID parameter to the XSLT stylesheet
XsltArgumentList xsltArgList = new XsltArgumentList();
xsltArgList.AddParam("pmID", "", pmID);
xmlItems.TransformArgumentList = xsltArgList;
|
by: Daimy |
last post by:
I meet the same problem below, please help me!
Thanks!
//written by some one
I have developed a windows forms user control, which I am going to host in
Internet Explorer..
I am familiar with the security settings requirement inorder to do the
|
by: Dennis Myrén |
last post by:
I have these tiny classes, implementing an interface through which their
method
Render ( CosWriter writer ) ;
is called.
Given a specific context, there are potentially a lot of such objects, each
requiring a call to that method to fulfill their purpose.
There could be 200, there could be more than 1000.
That is a lot of references passed around. It feels heavy.
Let us say i changed the signature of the interface method to:
| |
by: Dim |
last post by:
Hi
i am trying to create a Thread using _beginthread that will access data in a class but i keep getting a C2664: '_beginthread' : cannot convert parameter 1 from 'void (DBLR<T>&)' to 'void (__cdecl *)(void *)' with .
Anyone who can help, please do so, its driving me crazy. I know its most probably a type casting problem but i don't know what to do
Thank
/////////////////////////////////////////////////////////////code sampl
void qtest1(...
|
by: VB Programmer |
last post by:
I created a VB6 user control with a ActiveX Knob on it. Here's the simple
code:
Public Property Get Value() As Integer
Value = CWKnob.Value
End Property
Public Property Let Value(Value As Integer)
CWKnob.Value = Value
lblValue.Caption = CWKnob.Value
End Property
|
by: Marc Castrechini |
last post by:
First off this is a great reference for passing data between the Data Access
and Business Layers:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/Anch_EntDevAppArchPatPrac.asp
I use my own classes in the Business layer. I want to keep the Data Access
layer from requiring these classes so I tried passing a Datarow between the
layers and it seems to work good for me. Constructing the datarow in the
Class...
|
by: Brett Romero |
last post by:
Here's a table of data I'm putting into a collection:
CodeId CodeGroup CodeSubGroup Type
1 K K.1 Shar1
2 K K.1 MD5
3 J J.2 Shar1
I want to get the data in two ways:
Codes codes;
|
by: Bob Bedford |
last post by:
Hi all,
I'm stuck with some php code that runs out of time limit. This is due to a
long XML file process that has to save pictures on the disk.
What I've now:
- read XML file
- parse XML file
- for every article
- save datas in Database
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |