473,785 Members | 2,794 Online
Bytes | Software Development & Data Engineering Community
+ 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="openToolW indow()">LinkTe xt</A>
then the plain source code of my function is loaded into the window.

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

3) If I use
<P onClick="openTo olWindow()">Lin kText</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 1888
"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="openToolW indow()">LinkTe xt</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="openTo olWindow()">Lin kText</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="openTo olWindow()">Lin kText</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:unde rline;
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/rasterTriangleD OM.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
1682
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 shape="circle" coords="30,30,30" href="javascript:show_details('ring1');" alt="ring1" title="ring1"> </map> Is it possible to modify the
3
2030
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 solutions. 1. Opens a new Window at maximum size: window.moveTo(0,0,screenX=0,screenY=0) window.resizeTo(screen.availWidth+2,screen.availHeight+6)
5
2209
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 anything I'll write should be stuck on a single file. I thought about creating a funny pop-up. <a href="javascript:myFunction();"... that's because, as you will see, the code for the popup is pretty complex. I've insterted myFunction somewhere...
7
1821
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> <title>CSS Z-order Test</title> <script language=Javascript>
136
9457
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 code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to use. The above URL is version 1.0 (draft) that resulted. IMO, it is not a replacement for the FAQ,...
6
4207
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 help! bjorn
8
3677
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
2
2239
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 to include one URL's query string in the contents of a second URL. So for example, URL 1 might be http://www.example.com/pageone.html?param1=value1 and then (conceptually) URL 2 would be
11
1498
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 JavaScript disabled for security reasons (particularly on machines within a company network). So my questions are, 1: is there any estimate available of the percentage of users not having JavaScript available to them,
0
10329
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
10152
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
10092
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
9950
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 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...
1
7500
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 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...
0
6740
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4053
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
2
3650
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2880
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.