...

View Full Version : Basic question about null links



Psyantist
04-11-2003, 07:38 AM
So I'm trying to make a link that can be clicked
but goes nowhere. So inside my <a> tag I've put
onClick="return false". This works great for me
in both IE and Netscape. But my friend, using
the same version of IE that I have gets directed
to the page I specified with href=... This
baffles me. Any ideas?

<a href=nothing onClick="return false">Click</a>

Spookster
04-11-2003, 07:46 AM
<a href="#">Link</a>

<a href="javascript:void(null);">Link</a>

liorean
04-11-2003, 07:52 AM
It's onclick, not onClick. Wrap the value of the href attribute in double quotes. End the onclick with a semicolon. Never use empty hrefs - use "#" as minimum.

Psyantist
04-11-2003, 08:39 AM
Thanks guys, I gotta remember all that syntax.

I have a new problem now. After I fixed the null
link issue, everything began working just fine
in IE, but not at all in Netscape. Here is what
I'm trying to do: I have a bunch of thumbnails on
a page and when you click on them, it runs a
function that opens a window for the pic and sets
the background color and stuff. But for all the
commands I issue after the window is opened,
Netscape is telling me that the new window has no
properties. I know that's all kinda confusing but
I'm not sure what to suspect as the cause. Thanks
again for your help.

Spookster
04-11-2003, 08:59 AM
Originally posted by liorean
It's onclick, not onClick.

only if you want it to be XHTML compliant otherwise either way is fine.

brothercake
04-11-2003, 10:46 AM
You shouldn't be using # or javascript: links anyway - what about people who have no javascript?

Do something like this:

<a href="picture.jpg" onclick="pictureFunction('picture.jpg');return false">see the picture</a>

Psyantist
04-11-2003, 02:40 PM
I had something like that originally. But my
friend, using IE 6, had problems. It would load
the page in the href=".." completely ignoring
the return false. That's what prompted my
original post. Also, the site is pretty much
pumped full of JavaScript. I'm not sure that my
target audience will consist of more than a few
people whose browser's can't read JavaScript.
thanks anyway though.

Spookster
04-11-2003, 03:34 PM
Originally posted by brothercake
You shouldn't be using # or javascript: links anyway - what about people who have no javascript?

Do something like this:

<a href="picture.jpg" onclick="pictureFunction('picture.jpg');return false">see the picture</a>

<noscript>
Get a real browser!!!!
</noscript>

:D

Quiet Storm
04-11-2003, 05:48 PM
Originally posted by Spookster
<noscript>
Get a real browser!!!!
</noscript>

:D

LOL! :thumbsup:

Psyantist
04-11-2003, 06:59 PM
Let me try to be more specific about the problem
I'm having. The thumbnails on my page act as
JavaScript links to call a function. This
function opens a new window with a preformatted
html file in it with two frames in it. It then
loads a larger version of the picture file into
the top frame and sets the background color.
When the window is first created, the function
uses properties of the image (whose source is
passed as a parameter) to size the window
accordingly. I assign this new window to the
variable picwin. Everything seems to work fine
in IE but when I load the page in Netscape, it
gives me JavaScript errors that "picwin has no
properties. If anyone thinks they can help out
with this, take a look at the source for
http://www.prism.gatech.edu/~gte557z/zkhs/gal.html
It's a simple page so there isn't much there except for the thumbnails. Thanks.

Skyzyx
04-11-2003, 07:04 PM
Although I agree with Spookster as far as people getting real browsers, you also need to account for PDA's, Cell phones, or having to work on someone else's computer who has a crappy browser and you just need to get some information without having to pull your hair out over a non-compliant website telling you to get a real browser.

In this aspect, I'd have to agree with Brothercake. Make the website look cool for you and other people with browsers like yours, but add backwards (crappy browser) compatibility for other instances and devices.

Psyantist
04-11-2003, 09:16 PM
I certainly agree that I should have some
backwards compatability but it's also important
to consider audience. This site is actually for
a small business that will be catering to rich
people. It's just an unfounded guess, on my part,
that they will be accessing it from their homes
with up to date computer technology (as opposed
to cell phones and PDAs). It's not meant to
offer information either beyond contact info. I
would say its primary purpose is to display the
pics and right now that isn't working right for
me in Netscape...

Quiet Storm
04-12-2003, 12:23 AM
Have you tried something like this?:


<a href="javascript&#58;;" onClick="window.open('http://www.this.com/image.gif','pic','width=300 height=200');">

Psyantist
04-12-2003, 02:26 AM
Well it has to do a bit more than that
unfortunately. I dont want it to load just the
pic into a new window. I want it to load an html
file into it. That html file has two frames and
I want to load the picture into one of the frames
and then change the background color. Also, I
want the script to decide how big to make the new
window to accomodate the pic size instead of hard
coding it. So the answer to your question is no,
I haven't tried that exactly and while I'd be
more confident that something like that would
work with both browsers, it doesn't do everything
I want it to. Thanks anyway though. I
appreciate the suggestion.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum