+ Reply to Thread
Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: Javascript and links

  1. #11
    ellescuba27 is online now x10 Sophmore ellescuba27 is an unknown quantity at this point
    Join Date
    Sep 2011
    Posts
    150

    Re: Javascript and links

    If you want to use an image, try the javascript submit code, like:
    <a href="javascript:" onClick="document.(put the form name here).submit();"><input type="image" name="submit" src="image.jpg" width="126" height="18"></a>
    Just make sure you set the name attribute of the form to whatever you like and edit the code above appropriately.

  2. #12
    callumacrae's Avatar
    callumacrae is offline not alex mac callumacrae is just really nice
    Join Date
    Dec 2007
    Location
    Wellesbourne, England
    Posts
    5,162

    Re: Javascript and links

    Quote Originally Posted by ellescuba27 View Post
    If you want to use an image, try the javascript submit code, like:
    <a href="javascript:" onClick="document.(put the form name here).submit();"><input type="image" name="submit" src="image.jpg" width="126" height="18"></a>
    Just make sure you set the name attribute of the form to whatever you like and edit the code above appropriately.
    Instead of wrapping it in an anchor, why not just said the on click attribute of the input? Also, onclick should be all lowercase, and you should probably be using event listeners. You should also never use javascript:.
    I can customise your phpBB board. Send me a PM.
    lynxphp - info, tutorials and scripts
    "A forum post should be like a skirt; long enough to cover the subject but short enough to keep things interesting."

  3. #13
    mbengi.bongi83 is offline x10Hosting Member mbengi.bongi83 is an unknown quantity at this point
    Join Date
    Aug 2011
    Posts
    8

    Re: Javascript and links

    Thanks for the advice guys.

    Does the above apply to CSS Sprites? My friend forgot to tell me that the image is a sprite. The image has hover/visited states at the moment declared in a css id tag.

  4. #14
    callumacrae's Avatar
    callumacrae is offline not alex mac callumacrae is just really nice
    Join Date
    Dec 2007
    Location
    Wellesbourne, England
    Posts
    5,162

    Re: Javascript and links

    Haven't a clue, give it a try
    I can customise your phpBB board. Send me a PM.
    lynxphp - info, tutorials and scripts
    "A forum post should be like a skirt; long enough to cover the subject but short enough to keep things interesting."

  5. #15
    ellescuba27 is online now x10 Sophmore ellescuba27 is an unknown quantity at this point
    Join Date
    Sep 2011
    Posts
    150

    Re: Javascript and links

    Sorry for my coding, I learned Javascript 1.5 with a pretty bad tutorial book which had just as bad coding as that. As for the javascript: thing, it's just a placeholder because otherwise the link would lead to another page, and the reason I didn't put the event handler onto the image itself is that older versions of Netscape (I think that's the right browser) don't support it. You are right though, onClick should be lowercase - another habit of mine from the javascript tutorial book.

  6. #16
    callumacrae's Avatar
    callumacrae is offline not alex mac callumacrae is just really nice
    Join Date
    Dec 2007
    Location
    Wellesbourne, England
    Posts
    5,162

    Re: Javascript and links

    Quote Originally Posted by ellescuba27 View Post
    Sorry for my coding, I learned Javascript 1.5 with a pretty bad tutorial book which had just as bad coding as that. As for the javascript: thing, it's just a placeholder because otherwise the link would lead to another page, and the reason I didn't put the event handler onto the image itself is that older versions of Netscape (I think that's the right browser) don't support it. You are right though, onClick should be lowercase - another habit of mine from the javascript tutorial book.
    Use e.preventDefault() in an error handler to prevent the link from going elsewhere. Don't support the old versions of Netscape ;-)

    Try this for a good JavaScript book.
    Last edited by callumacrae; 12-07-2011 at 02:25 PM.
    I can customise your phpBB board. Send me a PM.
    lynxphp - info, tutorials and scripts
    "A forum post should be like a skirt; long enough to cover the subject but short enough to keep things interesting."

  7. #17
    mbengi.bongi83 is offline x10Hosting Member mbengi.bongi83 is an unknown quantity at this point
    Join Date
    Aug 2011
    Posts
    8

    Re: Javascript and links

    What is the correct way of incorporating the Javascript into the HTML? I assume the HTML given will be different as the code given refers to goto.php

+ Reply to Thread
Page 2 of 2 FirstFirst 12

Similar Threads

  1. Need help about javascript
    By lnakuma in forum Programming Help
    Replies: 12
    Last Post: 05-07-2011, 03:31 AM
  2. Javascript help
    By espfutbol98 in forum Programming Help
    Replies: 16
    Last Post: 06-24-2009, 01:45 AM
  3. Javascript Help
    By goldy30 in forum Programming Help
    Replies: 2
    Last Post: 11-30-2008, 04:24 PM
  4. javascript and external javascript files problem
    By delon in forum Programming Help
    Replies: 6
    Last Post: 04-27-2008, 12:41 AM
  5. JavaScript Ads
    By picasa in forum Programming Help
    Replies: 0
    Last Post: 03-22-2008, 05:16 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers