...

View Full Version : Your favorite thing to do with JavaScript?



fredmv
06-04-2004, 10:31 AM
I personally think appending a hidden iframe node in the document, transparently querying the server and then reporting data from the server on the containing page very cool stuff; just did that with a recent bookmarklet I wrote.

So what's your favorite thing to do with The World's Most Misunderstood Programming Language? ;)

Kor
06-04-2004, 11:38 AM
liquid design is may favourite application, I reckon...

jbot
06-04-2004, 11:41 AM
not got an outstanding favourite as such, but it does have to be said that bookmarklets are an exciting feature of JS.

of great interest is the JSRS method you've mentioned. the same thing could be sort of done using LiveConnect (Javascript-to-Java Applet-to-Javascript) coding, but JSRS makes it one less step in the process.

DOM-manipulation is cool to. Being able to add and remove elements on the fly is sweet. this is particularly useful working on JSP/Struts webplications. if you need a specific script on a particular screen, you can call a function in a global JS file which then appends a screen-specific file to the head. this helps keep the size of your JS files down and also means you don't automatically need to include them in each page. you just create the node when the script's needed. sweet! :thumbsup:

Willy Duitt
06-04-2004, 12:07 PM
Fred;

I am intriqued by Bookmarklets and use them often.
Can I see your Querring Bookmarklet?

.....Willy

BTW: To answer your question. I am of the same mindset as Jbot and enjoy client manipulation of the DOM as well as mathematics and writing javascripts to do something someone said couldn't be done. Javascript combined with Perl is a dangerous combination! ;)

Garadon
06-04-2004, 03:56 PM
Don't know what a bookmarklet is :P

I like to make graphical things and interfaces.

IE:3d sphere,Div windows,Dynamic Tables etc...

oh and I usualy use script blocks run php scripts in.

A1ien51
06-04-2004, 04:17 PM
Games (http://www10.brinkster.com/A1ien51/othello/)

jbot
06-04-2004, 04:21 PM
oh and I usualy use script blocks run php scripts in.

you mean like JSRS? or do you mean something else?

gonna give us an example?

fredmv
06-04-2004, 07:12 PM
Thanks for the responses guys.

Kor, liquid design, huh? That sounds more like a job for CSS, unless you're referring to something else.

jbot, definitely; bookmarklets have proven to not only be very cool, but very useful as well. And I wholeheartedly agree — the power to manipulate the DOM makes pretty much anything possible. It's incredible.

Willy Duitt, see next post. The purpose of this particular bookmarklet is to show the current standings of a poll without the need to constantly (well, manually) reload the page and it also tells you other things to (i.e., who's currently winning, and how many votes the loser needs to catch up). To run it go to <http://www.gamefaqs.com/poll/list.html>, go to the topmost poll, and paste the attached JavaScript code in the location bar and press Enter (I know you probably know this but this is for people who don't know how to use bookmarklets). The DOM Inspector (http://www.mozilla.org/projects/inspector/) was extremely useful during the creation of this script.

Garadon, no problem. It's a simple concept. A bookmarklet is merely a piece of JavaScript code that you can execute via the location bar. However, they're usually stored as bookmarks, hence, "bookmarklets". In general, they're scripts that perform some kind of useful (or not) action in the page using JavaScript. For more information you might check <http://www.bookmarklets.com/>.

A1ien51, pretty cool stuff. Games rock, but I've only built very simple ones (e.g., Tic-Tac-Toe). Perhaps I'll try a more complex project someday.

P.S. The bookmarklet provided below only runs correctly in Mozilla.

fredmv
06-04-2004, 08:06 PM
Attachment system is acting weird. See <http://www.fredvaughn.org/query.txt> for the bookmarklet.

allida77
06-04-2004, 08:51 PM
DOM. I am able to build pretty enhanced guis on the client working with js and the DOM.

Willy Duitt
06-04-2004, 09:42 PM
Thanks Fred;

I haven't had a chance to check it out yet and I'm leaving the office soon. But I just wanted to say that I appreciate your sharing. :thumbsup:

I do have a question tho. I realize IE has a limit (I think it is 256) on character length for Bookmarklets. Will this work as a Bookmarklet in Mozilla based browsers? Or is there a limit also?

Regardless, I know I can still use it with IE by calling an external file, but curious minds want to know. ;)

.....Willy

fredmv
06-04-2004, 10:08 PM
allida77, for sure. DOM functionality seems to be a common favorite and it's quite easy to see why.

Willy Duitt, no problem whatsoever. It will indeed work in Mozilla. In fact, it will only work in Mozilla. I've tested it in IE6 and Opera 7.51, but they both can't handle it.

joh6nn
06-04-2004, 10:25 PM
my favorite thing to do with javascript is a bookmarklet, as follows:

javascript:for (i in self) { if (typeof self[i] == "function") { if (self[i].toString().indexOf('[native code]') < 0) {if (confirm(self[i]+"\n\nEnd this function?")) {self[i] = null;} } } }

Basscyst
06-05-2004, 02:40 AM
My favorite thing to do is make little clientside apps that pull data to an HTML page, LOL - I guess that's the only thing I do. Make seemingly serverside apps that are all clientside. Makes for some scripts that do things lots say cannot be done with JS. Far less secure but they work and they've made me famous at work! :cool: Perhaps I will post one one day when I have a chance, they are quite usable.

Basscyst

the_bob
06-05-2004, 02:57 AM
this is gonna make me sound like a n00b, but i like to make scripts with never-ending alert messages to piss off my friends :D

missing-score
06-05-2004, 03:59 AM
heh.. what i do at school when my mates move away from a pc, is type in the address window:

javascript:for(i=1;i>0;i++){ alert("Whatever rude message I can think of"); }

and when they get back they wonder whats goin on lol.

fredmv
06-05-2004, 04:02 AM
Save yourself some typing. ;)
for(;;)alert('foo');

Garadon
06-05-2004, 07:49 AM
example:
you autogenerate a script block then you put a php file as its src this file is the run on the server and the php file returns the data in an autogenerated javascript.

bherrington
06-05-2004, 09:35 PM
I know it's basic, but my fave thing is multi-dimensional arrays. Partly because one of my friends (a non-scripter) thinks that I've just made up that phrase to make him feel insignificant.........

fredmv
06-06-2004, 09:44 PM
example:
you autogenerate a script block then you put a php file as its src this file is the run on the server and the php file returns the data in an autogenerated javascript.
I think I see what you're saying. You dynamically generate JavaScript on the server-side and then include it via:
<script type="text/javascript" src="js.php"></script>Of course this is where js.php would send text/javascript HTTP headers. This, however, isn't the JSRS ("JavaScript Remote Scripting") method jbot was referring to. Though it could still prove useful in some cases (e.g., populating an array with database data or other such information that could only be accessed on the server).

glenngv
06-07-2004, 05:57 AM
Games (http://www10.brinkster.com/A1ien51/othello/)
Me too. Check out my sig. :cool:
I developed my js skills in creating js games. And I honed it when I joined CF. :)

I've also made other games such as memory, (a not-so-intelligent) Othello and Master Mind.

sage45
06-07-2004, 03:08 PM
And I honed it when I joined CF. :)

Honed??? :p

-sage-

A1ien51
06-07-2004, 05:34 PM
Besides writing games , my other favorite thing is writing this: http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764574973.html

(I did not write the description of the book which I am yelling at the Tech editors to change!)

I have the book 75% done....should be 100% complete in 2 weeks...

Eric

glenngv
06-08-2004, 03:52 AM
Honed??? :p

-sage-
What's wrong with hone (http://www.google.com/search?hl=en&ie=UTF-8&q=define%3A+hone)? It can also be a verb.

jbot
06-09-2004, 04:14 PM
just occurred to me that one of the best things to do with JS is to prototype your own methods and properties, thereby creating extensions which overcome cross-browser problems more easily.

IE's really useful insertAdjacentHTML, insertAdjacentText and insertAdjacentElement methods don't exist in Mozilla, but it's possible make them so by prototyping a method based on HTMLElement. this way we don't need to write long-winded JS files, we simply call the method we need, since it's already been initialised in our extension library.

sweet :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum