SitePoint Sponsor |
|
User Tag List
Results 1 to 25 of 25
-
Jun 19, 2002, 09:25 #1
- Join Date
- Jan 2001
- Location
- Lawrence, Kansas
- Posts
- 2,066
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Why you should never use "javascript:" in a link
(Hopefully) useful tip for anyone who uses javascript. Don't use "javascript:" in a link URL to fire a javascript function. There is absolutely no reason to use it (apart from making bookmarklets but that's something else entirely). Browsers that don't support javascript will choke on it when for no extra cost you could use it to at least give them some kind of warning message.
Basically, instead of this:Code:<a href="javascript:doSomething()">click</a>
Code:<a href="noJS.html" onClick="doSomething(); return false;">click</a>
Even better, if clicking the link is meant to make a popup window appear use this:Code:<a href="popup.html" target="_blank" onClick="popUpFunction('popup.html', 100, 100); return false;">click</a>
I think the javascript: protocol thingy is deprecated now as well, but I can't find a link to back that up.
Cheers,
Skunk
-
Jun 19, 2002, 10:24 #2
- Join Date
- Feb 2002
- Location
- Gatwick, UK
- Posts
- 1,206
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
No - the "javascript:" thingy is NOT deprecitated!
It's a basic part of syntax.
But everything else is sound ( not that i care about people that don't use JS on my sites)
Flawless---=| If you're going to buy a pet - get a Shetland Giraffe |=---
-
Jun 19, 2002, 13:19 #3
- Join Date
- Jan 2001
- Location
- Lawrence, Kansas
- Posts
- 2,066
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
It's deprecated according to this: http://www.scottandrew.com/weblog/000284
-
Jun 20, 2002, 02:30 #4
- Join Date
- Feb 2002
- Location
- Gatwick, UK
- Posts
- 1,206
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
That's the first reference i've ever seen saying it is.
And i'm afraid i can't take that opinion at face value.
The syntax isn't depreciated, as far as i'm aware, since there is no replacement for it!
onclick doesn't do the same thing (don't get pedantic - we're obviously not talking about effects here, and there are places where you might specifically want to use javascript for a href - most of these have to do with fairly exotic techniques of how the call is handled - and i can't think of any right now otherwise i'd give you an example.
I agree it shouldn't be used if it can be avoided - but neither that fact, nor the opinion of some guy somewhere, makes it depreciated - that's down to W3C!!! ( who as far as i know have definately NOT depreciated the term )
Flawless---=| If you're going to buy a pet - get a Shetland Giraffe |=---
-
Jun 20, 2002, 06:58 #5
Do not use "javascript:"? Well thats very strange cause a lot of people use it and it aint a prob most of the time ... avoiding it is ok. but i dont think its wrong to use it .. it has to be accepted cause it is valid as a value that determines a keyword to be of the javascript.
-
Jun 20, 2002, 08:56 #6
- Join Date
- Jan 2001
- Location
- Lawrence, Kansas
- Posts
- 2,066
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
It's only a problem on browsers with javascript disabled. I know lots of people use it, my point is that they shouldn't because onClick provides the same functionality but allows you to use the href part to at least provide something to browsers without javascript - hence there's no reason at all to sue javascript: instead of onclick (there are no disadvantages to the onclick method but there are disadvantages to the javascript: method).
-
Jun 21, 2002, 18:33 #7
- Join Date
- May 2002
- Location
- Sydney, Australia
- Posts
- 214
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
redirect
It's only a problem on browsers with javascript disabled.
How can anyone surf the net without javascript anyway? They must have problems using 80-90% of all Websites.Thomas Oeser - Blueprint Software
Web Scripting Editor v 5.2 One cool Web editing tool.
3dcomputergraphics.com Coming Soon!
-
Jun 21, 2002, 19:04 #8
- Join Date
- Feb 2001
- Location
- New Zealand
- Posts
- 516
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Re: redirect
Originally posted by ThomasAesir
How can anyone surf the net without javascript anyway? They must have problems using 80-90% of all Websites.Oh no! the coots are eating my nodes!
-
Jun 24, 2002, 13:16 #9
- Join Date
- Jan 2001
- Location
- Ottawa ON
- Posts
- 315
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
The problem isn't just for people who have javascript disabled
Using href="javascript:" causes a problem whenever a user right clicks on the link and then selects "Open in New Window." Often, I see pages that opena link in a new window using javascript: and when I manually choose "Open In New Window," the link breaks. That's why the author's approach (using onClick) is a good one.
-
Jun 25, 2002, 05:45 #10
- Join Date
- Sep 2000
- Location
- Halmstad, Sweden
- Posts
- 7,400
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
I frickin hate sites that use javascript for opening links. It disables my beloved "open in new window", which really, really sucks.
Also, such scripting makes it toally impossible to browse the site from a PDA.Mattias Johansson
Short, Swedish, Web Developer
Buttons and Dog Tags with your custom design:
FatStatement.com
-
Jun 25, 2002, 05:54 #11
- Join Date
- Sep 2001
- Location
- Singapore
- Posts
- 5,269
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
i totally agree with Skunk and Mattias... i often "open a new window" too and i hate it when these sites try to tell me how i want to manage my life!
it's also not gonna work in text browsers (ok that's pushing it a bit but there are people who use lynx... check the stats page of any respectable website)
-
Jun 30, 2002, 16:25 #12
- Join Date
- Jul 2001
- Location
- Western CT, USA
- Posts
- 803
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
a *great* article on this subject:
http://www.evolt.org/article/rating/17/20938/index.html
-
Jul 2, 2002, 22:07 #13
- Join Date
- Dec 2001
- Location
- Japan
- Posts
- 655
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I say f*** the people without Javascript enabled. If your so damn paranoid that javascript scares you...
jeez!
Although I agree that "javascript:" doesn't need to be used. And I am more a PHP programmer than Javascript.
and whoever makes those PDA web browsers need to find a way to deal with Javascript... come on. Javascript is a PART of the web. Nothing can be done about that.
-
Jul 2, 2002, 22:22 #14
- Join Date
- Sep 2001
- Location
- Singapore
- Posts
- 5,269
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
most of them (i do enable JavaScript) aren't paranoid... i believe they're more bothered by popups and all that annoying things certain sites do... like adding themselves as a bookmark without prompting...
and i really hate it when a site breaks down because of some JavaScript error...Last edited by redemption; Jul 2, 2002 at 22:25.
-
Jul 2, 2002, 22:38 #15
- Join Date
- Feb 2001
- Location
- New Zealand
- Posts
- 516
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally posted by ZuulJin
and whoever makes those PDA web browsers need to find a way to deal with Javascript... come on. Javascript is a PART of the web. Nothing can be done about that.
I don't know about other PDA's, but the Palm ones use HTML 3.2 with a few limitations imposed by Palm, such as:
No frames, image maps or tricky text
No colour tags, anywhere
Limit tables to 140x150 and use them both sparingly and elegantly
No font tags
Bold face is <strong></strong> (XHTML)
Text size MIGHT respond to <big></big> and <small></small> tags
Use high contrast, very small images - with alt tags
Rely on word-wrapping to position your text correctly - that is, dont' put text into tables
Plan forms for both wireless and disconnected action
I'm not sure how relevant these limitations are to the current models and other platforms, but they were valid in May for Palm's.Oh no! the coots are eating my nodes!
-
Jul 3, 2002, 02:02 #16
- Join Date
- Sep 2000
- Location
- Halmstad, Sweden
- Posts
- 7,400
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
Originally posted by ZuulJin
and whoever makes those PDA web browsers need to find a way to deal with Javascript... come on. Javascript is a PART of the web. Nothing can be done about that.Mattias Johansson
Short, Swedish, Web Developer
Buttons and Dog Tags with your custom design:
FatStatement.com
-
Jul 3, 2002, 02:29 #17
- Join Date
- Feb 2001
- Location
- New Zealand
- Posts
- 516
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Well that is the point really, you have to remember that the PDA was developed as, and still is, a personal organiser. The possibilities of the synch cradle thurst the Internet upon it and the development of wireless gave it wings. But it has a way to go yet before it soars.
Oh no! the coots are eating my nodes!
-
Jul 3, 2002, 03:12 #18
- Join Date
- Sep 2000
- Location
- Halmstad, Sweden
- Posts
- 7,400
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
Actually, I use my iPaq H3870 to browse the internet completely wirelessly at 56k modem-speeds, with quite good results, actualy. I'd say that technology is ready - I can quickly check up if a domain is free while talking to a client, for instance. Amazon.com has a nice special version of their site for Pocket PC:s. I CAN read ordinary web sites in Pocket IE, but customized solutions are much sleeker.
Believe me when I say this - solutions customized for PDA:s are going to be a big oppurtunity.Last edited by M. Johansson; Jul 3, 2002 at 03:16.
Mattias Johansson
Short, Swedish, Web Developer
Buttons and Dog Tags with your custom design:
FatStatement.com
-
Jul 3, 2002, 03:24 #19
- Join Date
- May 2002
- Location
- Australia
- Posts
- 116
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
View your source right now on this page.. What do you see? good old javascript!
-
Jul 3, 2002, 03:34 #20
- Join Date
- Sep 2000
- Location
- Halmstad, Sweden
- Posts
- 7,400
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
Originally posted by Mr Chocolate
View your source right now on this page.. What do you see? good old javascript!Mattias Johansson
Short, Swedish, Web Developer
Buttons and Dog Tags with your custom design:
FatStatement.com
-
Jul 3, 2002, 03:54 #21
- Join Date
- May 2002
- Location
- Australia
- Posts
- 116
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I like using Javascript!
-
Jul 3, 2002, 05:30 #22
- Join Date
- Jul 2001
- Location
- Western CT, USA
- Posts
- 803
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally posted by ZuulJin
I say f*** the people without Javascript enabled. If your so damn paranoid that javascript scares you...
there's no reason (except laziness) that a site can't work great with javascript, and function without it. there are also legal, accessibility issues to consider, but those differ from company to company and country to country.
as a developer though, you should be aware that depending entirely on javascript could get you into trouble.
-
Jul 3, 2002, 05:41 #23
- Join Date
- May 2002
- Location
- Australia
- Posts
- 116
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Very true. I think it all depends on the site your working on if it's your own site then i say use all the javascript you want!. But if your making a site for a client you should make your site work in as many browsers as possible! But i think every body here knows that.
-
Jul 3, 2002, 16:05 #24
- Join Date
- Feb 2001
- Location
- New Zealand
- Posts
- 516
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally posted by Mr Chocolate
But if your making a site for a client you should make your site work in as many browsers as possible! But i think every body here knows that.Except lynx cos it is just screwed up!
Oh no! the coots are eating my nodes!
-
Jul 4, 2002, 01:27 #25
- Join Date
- Jan 2001
- Location
- Lawrence, Kansas
- Posts
- 2,066
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
If you design by using properly structured HTML (or XHTML) and keep all of your layout code in CSS there's no reason you wouldn't be able to get a page that works well in lynx.
Bookmarks