Popup Window...

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

function openPopUp(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.


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.

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


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;">


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.

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.


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.)


Happy Holidays,


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.