Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 14 of 14
  1. #1
    New to the CF scene
    Join Date
    Apr 2003
    Location
    Atlanta, GA
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Basic question about null links

    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>

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,280
    Thanks
    4
    Thanked 83 Times in 82 Posts
    <a href="#">Link</a>

    <a href="javascript:void(null);">Link</a>
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    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.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #4
    New to the CF scene
    Join Date
    Apr 2003
    Location
    Atlanta, GA
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #5
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,280
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Originally posted by liorean
    It's onclick, not onClick.
    only if you want it to be XHTML compliant otherwise either way is fine.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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>
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #7
    New to the CF scene
    Join Date
    Apr 2003
    Location
    Atlanta, GA
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #8
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,280
    Thanks
    4
    Thanked 83 Times in 82 Posts
    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>

    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #9
    Regular Coder
    Join Date
    Jun 2002
    Location
    Beyond Lament
    Posts
    424
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by Spookster
    <noscript>
    Get a real browser!!!!
    </noscript>

    LOL!
    Quíet Storm Designs ~ Art is not what you see, but what you make others see.
    · the Storms· || ·Ultraviolent Winter· || ·Was Einstein Wrong?· || ·It´s About Time!·

  • #10
    New to the CF scene
    Join Date
    Apr 2003
    Location
    Atlanta, GA
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #11
    Regular Coder
    Join Date
    Aug 2002
    Location
    Silicon Valley, CA
    Posts
    980
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #12
    New to the CF scene
    Join Date
    Apr 2003
    Location
    Atlanta, GA
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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...

  • #13
    Regular Coder
    Join Date
    Jun 2002
    Location
    Beyond Lament
    Posts
    424
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Have you tried something like this?:


    <a href="javascript&#58;;" onClick="window.open('http://www.this.com/image.gif','pic','width=300 height=200');">
    Quíet Storm Designs ~ Art is not what you see, but what you make others see.
    · the Storms· || ·Ultraviolent Winter· || ·Was Einstein Wrong?· || ·It´s About Time!·

  • #14
    New to the CF scene
    Join Date
    Apr 2003
    Location
    Atlanta, GA
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •