Tuesday 11 January 2011

Using JAVA To Resize Elements

I noticed a cool feature on a Google page while I was getting the custom search going. You can click on the divider between the left-hand bar and the main contents and it hides the left-hand bar. So I thought I'd try and get something similar going on my site.

I looked at the code on the Google page for a while but found it totally impenetrable. So I did a bit of searching around and decided that using some JAVA was the way to go. I found this page at w3scools.com. This is a fantastic site with clearly explained simple examples that you can run with quickly.

Rather than try and implement the ideas on my site straight away I though it best to try some sample bits of code to test the concepts needed.

The first of these is called test.htm. It's pretty simple - all it does is use 1 JAVA function to resize a box on the screen.

The second one is called test2.htm. This does quite a bit more. This has 4 JAVA functions. I have to admit I don't really understand the purpose of the getItem function but I left it in there as it's called by the second function toggleItem, which toggles the display status of box1 on and off.

There are two buttons on the screen, used to call the last two JAVA functions, which toggle the display status of box1 and re-size box2.

It didn't take to long to work it all out thanks to the helpful advice from w3scools.com. Now I need to implement the same ideas on my site.

No comments:

Post a Comment

keep it nice now