Jump to content

Adding nice bits to a site


ToonMariner

Recommended Posts

Hi there, posted something similar on webdeveloper.com but to no avail....

What I want to do is add javascript to enhance the users experience.  I have a site that is created in xhtml 1.1 and the whole thing works very well at the moment without any client side scripting so in terms of accessibility on that front I am happy.

Now the target attribute for an achor tag is not valid markup (even though browsers still seem to support it) so I had a few associate links that with JS off open in the current window but open in a new window if it its on using:

<a href="http://www.nr-foundation.org.uk/" title="Northern Rock Foundation" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;"><span>Northern Rock Foundation</span></a>

now this works beatutifully.  What I would like to achieve is somethig similar for the shopping cart I have built but calling a JS function instead off window.open.  Something like this:

<a href="/index.php?action=additem&amp;id=34&amp;num=3" title="Add Item" onclick="cartAdd(this.href); return false;" onkeypress="cartAdd(this.href); return false;"><span>Add Item</span></a>

My intention was to use JS to split the url so I could grab the action, id and num and use those parameters in an ajax request to update the shopping cart without having to 're-fresh' the whole page.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.