• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 262
  • Last Modified:

Popup Window...

I've got some javascript code to open a popup window:

function openPopUp(url,name,features) {
  window.open(url,name,features);
}

The only problem is that the examples use this with 'onclick', which is good for buttons but not that good for image rollovers, where I need the cursor to change to a 'hand'.  I can put an 'HREF' statement in (which gets the cursor to change) but how do I get it to do nothing (i.e. not change my current page to something else)?  The best I can do at the moment is point the 'HREF' to myself so it reloads the current page when the popup window is called.

Cheers.

Chris.
0
kryzb
Asked:
kryzb
  • 3
1 Solution
 
TTomCommented:
You need to add "return false;" to the onClick event handler for your link.  That should prevent the page from doing anything other than the popup.

Tom
0
 
memilaviCommented:
There are two options for this:
1. Create function named f_dummy, which does nothing:
function f_dummy()  {

      return;

}
and point the HREF to this function:
<A HREF="javascript:f_dummy();">
2. (And a better one) Create a style for this image this way:
<IMG SRC="..." STYLE="cursor: hand;">



0
 
TTomCommented:
memilavi:

Interesting to change the style of the cursor, but, two points:

I don't think this will work real well with NS (it doesn't really like inline styles), and, I think the purpose of the exercise is to open a popup when the image is clicked.  I don't think NS supports the onclick event for images (but I may be wrong about that).

Since the point of the question was sort of how to stop the home window from changing when the link is clicked, "return false" should do it nicely.

Tom
0
 
kryzbAuthor Commented:
I tried the 'return false' suggestion first and it works perfectly in both IE and Netscape, so I'm quite happy.

Tom, feel free to propose this as an answer.  Cheers.

Kryz.
0
 
TTomCommented:
Kryz:

Question answered.

(FWIW, you should be able to "accept comment as answer", although that may not be available if you are using the oldlook version.  Just need to be careful that the comment you accept is the one which answers the question, i.e., the comment accepted is the one BELOW the comment header bar.)

Thanks!

Happy Holidays,

Tom
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now