Need help with a website sidebar, HTML and Java.

Community Forums/General Help/Need help with a website sidebar, HTML and Java.

WERDNA(Posted 2011) [#1]
Hey folks!

I have a hopefully quick question.

I'm working on editing a website for a friend(www.spanishvillageart.com)
and I need a little help, since I'm kind of learning this as I go along.

I need to put the 'Sign up for our newsletter' in the sidebar. I already
have the HTML code for this, and know how to modify that,
but I'm not sure how to stick it into the sidebar, since the sidebar
is seperate from the main body of the web page, and is made in
Java.

I can't show you the code itself, since the site isn't mine, but I
just need some general advice on how to stick HTML code into
a Java sidebar, or how to make that sidebar read from an HTML
file so the same effect is achieved.

Cheers!


Yasha(Posted 2011) [#2]
You sure you mean Java and not JavaScript?

Because if it's Java... that's a significantly more complex task. And completely different.


WERDNA(Posted 2011) [#3]
lol, shows how little I know about Java :)

I checked, and it's a JavaScript file.


Jesse(Posted 2011) [#4]

I can't show you the code itself, since the site isn't mine,...


you know that aside from the flash files all of the source code is fully available for any one to see.
any way I don't know much about javascript as I am learning it myself but If the code is in html then you are going to have to insert it before or after the script declaration between the "<td> </td> of the table with the sidebar.
right before or after this line:
<script language="JavaScript" type="text/javascript" src="sidebar.js"></script> 

and of course it is going to be displayed above or below the sidebar props depending on where you put it.

if you want to insert it in the "sidebar.js" code than I "think" that it has to be coded in Javascript for it to work.

the little I know I have learned from here:
http://www.w3schools.com/js/default.asp


ima747(Posted 2011) [#5]
Javascript is interpreted (not compiled, ergo it is always in source form) by the web browser at runtime. This means the source has to be readable to the web browser to be run. By extension anything your web browser can read so can you. JavaScript can be embedded in a page directly, or (as Jesse indicated) the page can link to a resource file containing the code. If it's embedded just look at the page source. If it's linked then look at the page source and find the link (again as Jesse indicated) and visit that file to take a look.

Not sure exactly what you're doing but javascript to create a side bar sounds less than optimal to me. Reasons:
If someone has JavaScript off (still happens a lot) or no JS support, you have no side bar and presumably your site's navigation is crippled.
As with all things on the web, every browser is different. You're going to have to test that code in (minimally) IE (preferably a number of versions from 6 - current with and without compatibility mode), firefox, chrome, safari and then possibly Opera etc etc etc. And expect problems...
Why not use HTML? No code problems, no interpretation problems, far less testing (HTML actually works these days now that IE 6 is a dinosaur). Also less to load so the page loads faster.
Why not use CSS? Like HTML it's far more likely to work, far easier to make, and far easier to test (though you do need to test more than plain HTML). It's also much easier to make large revisions in future, and the user's browser can modify it on the fly as needed for their user experience. AND it can pull off a lot of the tricks you're likely to be wanting from javascript...

Just my thoughts :0)


WERDNA(Posted 2011) [#6]
Thanks guys, I'll try some of the things you suggested.

I can't edit the sidebar itself(I.e, it's stuck being Java script), because I don't have access
to the main code that puts it all together, only to the individual files. So I can't really
add new ones, just edit the ones that are there.

I'll 'attempt' to rewrite the code in Java, and see if it works. If not, I might just position
it somewhere else on the page.

Thanks,


Jesse(Posted 2011) [#7]
based on how you are interchangeably using Java and JavaScript I don't think you understand what is going on Werdna. I'll try to explain it with a little bit more detail:

JavaScript is an embedded computer language built into most browsers.
Java is a plugin interpreter for a different computer language similar to JavaScript but not the same.
Java works in similar fashion as Flash you need to download the plugin to get it to work in your browser.
JavaScript can be embedded in the HTML file you just have to tell the browser that it's Javascript with the "<script>" and "</script>" tags. you can program it just like you do any other language. with; variables,loops, and if statements. the code can also be written in a text editor just like HTML saved with the extention "js" it can then be access by using the script tags in the html page.

the source you are looking for in the page you are trying to edit is the script by the name "sibebar.js" and that is the left side bar. To look at it all you have to do is load it into your browser like this:
http://www.spanishvillageart.com/sidebar.js
if you have direct access to the server's user account for the page, you can also download the js file, edit it with a text editor, and upload it back up to the server and the changes will take effect immediately as when you are writing html code. One thing to note with JavaScript is that the browser will not report any errors with it. It will just stop running the script or that specific part.

note:
the right side bar is just plain html code with CSS and some imbedded JavaScript. you might want to consider placing it there. look for the section "<!-- WAS PICTURE -->" and that is where the right sidebar start.


I am wondering. Are you trying to sell services beyond your skills? :)

Last edited 2011


WERDNA(Posted 2011) [#8]
Thanks for the clarification Jesse!

I am wondering. Are you trying to sell services beyond your skills? :)

Not really, it's all volunteer work. And I can usually fuddle my way through stuff, it
might just take awhile. Yeah, I'm not great at this kind of thing, but I'm about the only
option on hand. The guy who was handling site updates died ;(

Also the person having me update the site says the newsletter signup box actually
looks fine in the middle of the page instead of the sidebar, so I guess I don't need to
bother with Javascript yet. Although it will certainly be handy having all of this advice
on hand for when I do inevitably need to edit it.

Thanks!


Yasha(Posted 2011) [#9]
Mmm... it's seriously stretching the terms to even call Java similar to JavaScript.

Java is compiled, high-performance, statically-typed (all superstrict, all the time), object-oriented (and not the wussy you're-allowed-procedural-code kind of "object oriented"), and normally used for writing server code and big applications. Or, as Jesse points out, compiled applets that need a browser plugin.

JavaScript is interpreted (by browsers... compilers do exist but are rarely used), completely dynamically typed (any var can hold any data type at any time), procedural with shades of OOP and FP (OO is prototype-based: no types/classes; and functions are fully first-class objects in their own right). JavaScript is the one normally used for lightweight stuff on the client side like animated menus.

Basically, the languages have completely different design philosophies and were devised by different people. Neither is based on the other to any meaningful extent (according to one of the developers, JavaScript is actually based on Scheme (Lisp), disguised in C-like syntax. Make of that what you will).

EDIT: My I do type very slowly. Sorry to mess up your thread Werdna, this was supposed to be a response to Jesse's comment!

Last edited 2011


Jesse(Posted 2011) [#10]
@Yasha
I did make an assumption based on my minimal knowledge of Java. and thanks for clarifying that for us both. I have glanced at Java only a couple of times and it seem to me similar hanse my conclusion but thanks again for clearing that up.

@Werdna
good luck with it. HTML, CSS, and JavaScript are easy to learn, at least it has been for me. a few months ago I rented some server space to program my own website with out any knowledge of what I was doing. It has been fun learning to program it from scratch. The link is in my sig. if you are interested in looking at it. it probably is too basic and there are things I can do to reduce the amount of code but I am sure I will be able to improve it over time. I had a forum but I removed it as I will have to read more on it to make it work to my liking. I do have a blog but forgot the password a few weeks after I installed it. I will remove it too and might reinstall it if I change my mind.


Yasha(Posted 2011) [#11]
Hey Jesse... I hope my post didn't come across as confrontational. I was just trying to be informative, sorry if it sounded like a put-down. Judging by a lot of my recent posts I seem to have turned into quite the cranky old man - I'll try to stop that!

@Werdna... I should second the vote for W3schools as a source of tutorials. I found them very helpful myself. Although the tutorials could really be a bit longer than they are, one thing you know is that everything there is (probably) right - W3schools set the standard for what is good HTML, CSS and so on, so it's useful for them to also be writing the tutorial!

One thing to note with JavaScript is that the browser will not report any errors with it.


Actually you can get plugins for Firefox (and probably the other major browsers) that do this - possibly WebDeveloper or FireBug or something like that (I forget the name, sorry)? Anyway, there are plugins that add little icons indicating whether the code is properly standards-compliant and an error console for any errors that occur - this is invaluable when testing your own designs.


Jesse(Posted 2011) [#12]

Hey Jesse... I hope my post didn't come across as confrontational.



Don't worry, no harm done. I was expecting someone to say something along the lines but maybe a bit hostile as I expect when I say something I don't know much about.

I have been programming on a mac and for debugging, I have found the included debugger in safari(hidden has to be activated to display in the menu bar) to be really good. it shows up in the browser as "Develop" and is better than the one included in Opera. I haven't tested the IE, FF or Chrome so I can't give my opinion about them. And yes, I should have mentioned that on my previous post.

Last edited 2011