PDA

View Full Version : Javascript/HTML - Prompt Reply Required Please... (READ THIS ONE NOT THE OTHER ONE... SORRY)


Ace
06-15-04, 01:27 PM
Oops I forgot to use the code thing in the other one. I forgot HTML was enabled in posts. So I messed it up a bit. Sorry. Here goes take 2:<BR><BR>I have a major headache with a website I'm making for someone and I'm running out of time. I essentially need to add a locked textbox with scrollbars. A frameset and frame with text in and scrollbars would do but I don't want to resort to that because of limited cross-browser support. I've found a prime example of what I want on another site but I don't want to copy code directly. It seems relatively simple but I'm no JS expert and I really could do with someone explaining this code to me... the example is <a target=new class=ftalternatingbarlinklarge href="http://www.onelifestyle.co.uk/?thefitmap">here</a> but to save you the trouble here's the code I'm looking at (taken from above site - these bits seem to be the relevant bits):<BR><BR>I basically understand the stuff after the [HERE]. What I don't get is: <BR><BR>what's load1.js? Do I have to have this file with the webpage? Is it client based? What would the client require to view it?<BR><BR>the second script tag doesn't state a script. Is it loading the load1.js thing? <BR><BR>how come HTML is popping up in the brackets and why? What does that mean? No close </style> tag?<BR><BR>what does document.writeln do?<BR><BR>If you can shed any light on this thanks... if not thanks for reading this far lol.

lazyrunner50
06-15-04, 01:27 PM
Hey. Sorry no one has responded earlier. If you have not already figured the problem out yet, hopefully I can help out a little.<BR><br><br><< <i>what's load1.js? Do I have to have this file with the webpage? Is it client based? What would the client require to view it?</i> >><br><br> A *.js file is an external javascript file. If your clients computer is javascript enabled, it can use a *.js file.<BR><br><br><< <i>the second script tag doesn't state a script. Is it loading the load1.js thing?</i> >><br><br>Not sure what you mean by this one...I'll give it a shot though...If you are talking about the <'/script> tag that is just the closing tag. There should not be anything else specified inside the tag. Now, between the tags is a different story. There is nothing there because the source of the script is denoted by the src= in the first <'script> tag. This just means that the javascript in the page will be using the functions and other stuff from the load1.js file. You can also specify other javascript functions on the page along with the *.js file which you want to use. Just make sure if you do that, you have a seperate set of script tags and you don't name the stuff (functions, variables) the same things as you do in the *.js file. <BR><br><br><< <i>how come HTML is popping up in the brackets and why? What does that mean?</i> >><br><br>Also not sure what you are asking here. Uum..the menus on the right side are populated with text from the HM_Arrays1.js file which referenced in the code of the load1.js file. Oh..and to make things more fun, the load1.js file also loads a *.js file which is determined by which browser the user is using. I haven't looked at the code enough, but it more than likely does something like reference a *.js file called something like netscapeFile.js for Netscape or ieFile.js for Internet Explorer. The reason for this is that javascript is horrible when it comes to cross browser functionality, so certain things will not work in one browser that easily work on others. A common practice is to just create a custom *.js file which is loaded based upon what type of browser the user has.<BR><br><br><< <i> No close tag?</i> >><br><br>Where??<BR><br><br><< <i>what does document.writeln do?</i> >><br><br>It writes a line of text to the screen (aka document)<BR><BR>On a side note, while Javascript is good for client side stuff, if you are going to get much more into websites, I suggest you learn something like ASP, PHP, or learn Java so you can make JSP files. All of these scripting languages spit out pure html that will run on any browser out there. Sure, you can't add some of the fancy stuff you might be able to with javascript, but you can be sure it will run under any browser, and you can create a much more secure site that can change based on content from a server as well as user interactions on the client side rather than just the latter.

Ace
06-15-04, 01:27 PM
Thanks a lot Lazyrunner, I appreciate your response, you've been very helpful.<BR><BR>I'll also consider your advice about the languages at the end of your post. I was considering learning JS first, but you have changed my mind (which is not an easy thing to do, believe me hehe).

lazyrunner50
06-15-04, 01:27 PM
Haha. Thanks. Yeah, I really like some of the stuff you can do with Javascript, but it is horrendously insecure, and when it comes to cross browser support...forget it. That is unless you learn about all the quirks in different brands of browsers. What makes it worse is that even with the same brand of browser your program could behave differently based on the version.<BR><BR>By the way, if you are still interested in looking at the *.js files on that website, all you have to do is go to the root directory of the current page you are on (ex. if the page is located at http://www.somesite.com/someFolder/somePage.html go to http://www.somesite.com/someFolder/) and type in the name of the *.js file including the extension. You should be able to download the file. <BR><BR>

Ace
06-15-04, 01:27 PM
Crumbs... how come I never thought to do that. I'll blame it on old age hehe.<BR><BR>I take it the code at the bottom is trying to satisfy half a million different browsers... eek...<BR><BR>What would you honestly suggest I get to grips with over the summer that would be helpful in creating relatively small sites, not for ecommerce or anything like that. I can't see myself learning more than one, but I'm prepared to give anything a go. I'm a little reluctanct to try Java after looking through a Java book I have here, but if you think that would be most useful. I have a PHP book too. My concern about that is hosting - a lot of hosts (esp. free hosts) don't support PHP. As for ASP, I'm not sure about hosting for that. I've looked at PHP and ASP websites. I guess PHP will be the more useful of the two. I tried setting up a PHP "server" on my PC a while ago but failed. *Buries head in shame*. I must have another look at it at some point.<BR><BR>Anyway, thanks for your help LazyRunner!

lazyrunner50
06-15-04, 01:27 PM
Humm...that's a tough one...I only just started learning jsp's and servlets (both use Java), but they seem to be really useful. I would not reccomend them for a first timer though. Since I have not used jsps or servlets outside of a classroom setting, I don't know of any good hosts either.<BR><BR>PHP & ASP are both pretty good. I wish I could reccomend one over the other, but I guess just go with the one for which you can find more hosts (or the one you feel more comfortable with). A really good host is www.3essentials.com (the one I am using). You can probably cheaper or free ones, but you can do both PHP and ASP with them. I think the plan is something like $4.00 a month. The good thing is that you can play around with them both and see what each one does.<BR><BR>Not sure why your install of php didn't work. If you didn't get it already, try phpTriad. It has mySQL (a free database that you can use with php), and Apache (the webserver that runs php code). If you decide to go with ASP, just use the Windows CD and install IIS. After installing IIS go to http://localhost. It will have instructions on how to set everything up on the page that comes up. <BR><BR>Yep, that code figures out which browser. See the bad part isn't figuring out which browser (good ol' cut and paste!!), but actually remembering which browser does what.

Ace
06-15-04, 01:27 PM
Thanks Lazyrunner. When I get a spare few minutes in this exam period, I'll have a mess around with both of them. I'm used to VB, and I gather the ASP syntax is similar, so I should be OK with that. I started learning the basics to PHP a little while ago, but I've forgotten almost everything now. Back to the drawing board I guess!<BR><BR>That's a very cheap host too - £2 a mo with PHP and ASP. Woah! I'd normally be looking at £6 for package with an 8 page limit LOL. I'll certianly bear that site in mind, perhaps for the summer when I have some more time on my hands.<BR><BR>Many thanks for your assistance, although this probably won't be the last you'll hear from me hehe.

lazyrunner50
06-15-04, 01:27 PM
No problem. Glad I could help.