473,466 Members | 1,405 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Javascript in HREF attribute

Hi,

I need some help on a simple question: I have a link that should open a new
window (no action in main window), which is realized by a function that
calls window.open(). The function itsself works fine, but here is the
problem:

1) If I use
<A HREF="openToolWindow()">LinkText</A>
then the plain source code of my function is loaded into the window.

2) If I use
<A HREF="" onClick="openToolWindow()">LinkText</A>
my function runs correctly, but the original window loads my start page.

3) If I use
<P onClick="openToolWindow()">LinkText</P>
everything works like intended except that my paragraph does not behave like
a normal hypertext reference, i.e. it is not undelined, has a different
color, and the mousecursor does not change into the "hand"-cursor on
mouseover.

How would the cracks handle this problem? The document in the main window
should not be reloaded, if possible. It is a php-script that performs some
database action, and I want to keep the workload low for my server.

Best regards,
Bernd

Jul 20 '05 #1
1 1859
"Bernd Liebermann" <12**@bernd-liebermann.de> writes:
I have a link that should open a new window (no action in main
window), which is realized by a function that calls
window.open(). The function itsself works fine, but here is the
problem:

1) If I use
<A HREF="openToolWindow()">LinkText</A>
then the plain source code of my function is loaded into the window.
Surpricing. I would have expected a "page not found" error. Do you mean
with "javascript:" in front? And did you forget the parentheses?

In any case, forget it.
Read <URL:http://jibbering.com/faq/#FAQ4_24>.
2) If I use
<A HREF="" onClick="openToolWindow()">LinkText</A>
my function runs correctly, but the original window loads my start page.
Yes. You should add "return false" after the call to prevent the normal
operation of the link. It's in the link above too.
3) If I use
<P onClick="openToolWindow()">LinkText</P>
everything works like intended except that my paragraph does not behave like
a normal hypertext reference, i.e. it is not undelined, has a different
color, and the mousecursor does not change into the "hand"-cursor on
mouseover.
Then style it:
---
<style type="text/css">
p[onclick] {
color:blue;
text-decoration:underline;
cursor:pointer;
}
</style>
---
You should probably give it a class, because IE doesn't understand CSS 2,
so it won't understand the attribute selector "p[onclick]".
How would the cracks handle this problem?


Return false.

/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 20 '05 #2

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

Similar topics

4
by: Nick | last post by:
For example, I have the following code: <img src="photo_ring_r1_c1.jpg" title="" alt="Rings" style="width: 200px; height: 150px;" usemap="#photo_ring_r1_c1"> <map name="photo_ring_r1_c1"> <area...
3
by: annon | last post by:
I've noticed that some problems come up frequently that are of importance in writing web pages, because they're pretty fundamental points. For general reference, here are some collected...
5
by: Lucian Sandor | last post by:
Hello everyone, While I'm a newbie here, I a not new to google, so please don't send me back, it would be useless. First of all I have to specify I am working on a Blogger.com template, therefore...
7
by: f1crazed | last post by:
Ok, The following html works wonderful in IE. It does not work in FireFox. Can someone please tell me the work around for FireFox to get this to work. HTML DOCUMENT: <html> <head>...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
6
by: b. hotting | last post by:
Hi, I don't see why this won't work, it are 3 links, the last one (a get) does work, but the first 2 won't. i would like to use a post, through hidden input types any idea? thanks for your...
8
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
2
by: j.e.frank | last post by:
I am puzzled by some behavior that I'm seeing and I hope that someone can enlighten me. It will take me a few moments to explain the problem, but it does relate to javascript eventually. I need...
11
by: John Pote | last post by:
Hi everyone, I've just started adding JavaScript to some of my web pages. It then occurred to me that of course not everyone may have JavaScript in their browser and more probably may have...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
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...
1
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
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...
0
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.