The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 6 of 6

Thread: Can I use onClick to just go to a URL

  1. #1

    Can I use onClick to just go to a URL

    OK I admit I am violating CSS by wrapping an HREF around a div but I have done this before with full knowledge that it is not done but it worked in other instances including empty divs & nested divs with other javascript widgets like Hide All except One with no problem.

    The one that this is not working is a javascript scroller based on this example.
    http://jscroller2.markusbordihn.de/example/

    My HREF does click thru in FF but not in IE.

    Could I try something like
    Code:
    <a href="http://yahoo.com" OnClick="MyFunction(getURL);" title="Click here">

  2. #2
    actionAction's Avatar
    1,142
    posts
    humanBeing._beard=true;
    It's not CSS standards, it's W3C and DOM standards that are being violated by this. Yes, you can use onclick to just go to a url using window.location.href = 'yourfile.html', but it should be in your div element, not in an anchor tag wrapping the div. You can put a regular anchor tag inside of the div (also inside of a noscript) tag to ensure that users without Javascript will be able to use your site.

  3. #3
    Quote Originally Posted by actionAction View Post
    It's not CSS standards, it's W3C and DOM standards that are being violated by this. Yes, you can use onclick to just go to a url using window.location.href = 'yourfile.html', but it should be in your div element, not in an anchor tag wrapping the div. You can put a regular anchor tag inside of the div (also inside of a noscript) tag to ensure that users without Javascript will be able to use your site.
    Thanks!

    this works

    Code:
    <div id="wrapp" onClick="window.open('http://yahoo.com','_blank');">
    One more question, is there a way to tell this method of linking to another page to show a hand cursor for useability?
    Last edited by somnamblst; July 23rd, 2008 at 12:47 PM.

  4. #4
    actionAction's Avatar
    1,142
    posts
    humanBeing._beard=true;
    No problem! In the css, put:

    #wrapp{/* not sure if there are supposed to be two ps there in wrap */
    cursor:hand;
    }

  5. #5
    Quote Originally Posted by actionAction View Post
    No problem! In the css, put:

    #wrapp{/* not sure if there are supposed to be two ps there in wrap */
    cursor:hand;
    }
    I do have that in my style, only appears to work for IE but the addition of onClick="window.open seems to have overridden that style.

    I misspell words like wrapp on purpose so I lessen the likelihood of other style sheet conflicts.

  6. #6
    actionAction's Avatar
    1,142
    posts
    humanBeing._beard=true;

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012