MrAdam Posted October 10, 2008 Share Posted October 10, 2008 Just a quick question about working around non-js users... I couldn't find really anything useful through searching so thought perhaps somebody might have already dealt with this.Basically I'm creating a portfolio for myself. I want to have some really smoooth js features that gives the user that added wow effect, without making it unusable for users with js disabled. One of the features will be they click a thumbnail and up pops a nice big image of the site. I'm doing it with the onclick event. what I'd like to be able to do is say: <a href="non-js-page.php?site=##"><img src="img/##_thumbnail.jpg" onclick="previewSite('##');" /></a> where the onclick handles the js users, and the link handles non js users. I've tried a few things however the above runs the javascript then goes to the link. Does anybody know how I could get it to work?Cheers for any help! Adam Link to comment Share on other sites More sharing options...
Synook Posted October 10, 2008 Share Posted October 10, 2008 Err? If JS is disabled, then the JS function won't run. That code should be fine (although why not put the onclick handler in the anchor?) Link to comment Share on other sites More sharing options...
MrAdam Posted October 10, 2008 Author Share Posted October 10, 2008 Yeah but if the user has js enabled it runs the code, then after still goes to the page.. And its called with the onclick because I still want to be able to link non-js users to another page in the anchor..Cheers anyway though.. Adam Link to comment Share on other sites More sharing options...
global.user Posted October 10, 2008 Share Posted October 10, 2008 Hm, that's not a good day ! It's been two times I post just after someone because of typing time !!! Anyway, that's orig message:No I think he means the OTHER way. Yes, when Js is disabled, the link will go, not the script. But if Js IS enabled, the script will go, then the link (and he doesn't want that).Maybe use <noscript> ? Link to comment Share on other sites More sharing options...
MrAdam Posted October 10, 2008 Author Share Posted October 10, 2008 Ah yes. of course.. So would something like: <a href="<noscript>non-js.php</noscript>"><img src="..." onclick="previewSite(##)" /></a> Be the way to go? I've not used noscript before really, heard of it tho.. Am going to hav a quick read-up now..Cheers for the reply. Adam Link to comment Share on other sites More sharing options...
global.user Posted October 10, 2008 Share Posted October 10, 2008 More like the inverse: <noscript><a ref ... /></noscript>Proof read it, cause i'm not so sure... I haven't really used it either Link to comment Share on other sites More sharing options...
Synook Posted October 10, 2008 Share Posted October 10, 2008 Oh I se what you mean, Adam.The easy solution is to set your JS function to return false, and then to do: <a href="non-js-page.php?site=##" onclick="return previewSite('##');"><img src="img/##_thumbnail.jpg" /></a> You could use noscript, but it is more logical to return false. Link to comment Share on other sites More sharing options...
Ingolme Posted October 10, 2008 Share Posted October 10, 2008 You can do this:<a href="non-js-page.php?site=##" onclick="previewSite('##'); return false;"><img src="img/##_thumbnail.jpg" /></a>It will not open the link if javascript is enabled. Link to comment Share on other sites More sharing options...
MrAdam Posted October 11, 2008 Author Share Posted October 11, 2008 Beautiful. Adding "return: false;" after calling the function worked a charm! Cheers mate! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.