By using this site, you agree to our Privacy Policy and our Terms of Use. Close

Forums - PC Discussion - Any Javascript masters here?

>_>; I'm trying to work with Javascript and I need some help. If anyone here knows it, could you possibly messege me or if you have AIM, contact me at SageErk? Thanks! 



Around the Network

What's the problem?



When I work with web design, I generally use PHP when creating 'include' files that have information that doesn't change depending on the page. For school, I'm recoding my entire school's website because, well, the last web designer though putting tables inside tables was the best way to create a layout for a website. >_>; However, the schools webserver doesn't support PHP and therefore, I'm restricted to using Javascript to accomplish something similar to this. But, I'm not a Javascript expert and I can't figure out why my code isn't working. include.js: function header() { document.writeln("<html>"); document.writeln("<head>"); document.writeln("<title>Hereford High School</title>"); document.writeln("<style type="text/css">"); document.writeln("<!-- @import url("/style.css"); -->"); document.writeln("</head>"); document.writeln("<body>"); document.writeln("Test Header"); } function footer() { document.writeln("Test Footer");

document.writeln("</body>"); document.writeln("</html>"); } index.html:

<script src="/include.js"></script>

<script language="JavaScript">header();</script>

Test

<script language="JavaScript">footer();</script>



You should not be using JS to do the things you are trying to do. Maybe you are trying to do some PHP type things(I have never used PHP).  I am no expert on DOM or JS, (I write back-end applications using Java and C#) but can you utilize the document object without having started the html or head tags?

 

Use this for your script tags as well - <script type="text/javascript">



its easier if you learn java or c++, i have been told i haven't taken javascript year i am second year second semester student.



Around the Network
Jo21 said:
its easier if you learn java or c++, i have been told i haven't taken javascript year i am second year second semester student.

Java and C++ do not have much use for creating web sites.  JavaScript is the way to go and is in fact an object oriented language(like Java and C++), just a slightly different style of inheritence and object creation. 

Can the OP please describe exactly what you are trying to accomplish?  JS can be quite powerful when used in conjunciton with CSS.  Maybe try out some libraries that are out there such as jquery or prototype.

A very basic html page with js would be as such.

<html>

   <head>

      <script>

      </script>

   </head>

   <body>

   </body>

</html>

Use CSS and html fragments to create the static portions of pages and then include JS to add any dynamic functionality.  There are frameworks available that help the process.

You could also use JS to create the static portions using DOM and then apply styles to them.



You know, using Javascript where PHP would be needed isn't a great idea... Javascript is a client-side script while php is on the server. You don't really want to send everything to the client.



How many cups of darkness have I drank over the years? Even I don't know...

 

Jo21 said:
its easier if you learn java or c++, i have been told i haven't taken javascript year i am second year second semester student.

 

Java is an extremely slow language when you run its applications and C++ is more for program coding than it is for web-page applications. JS is actually meant for some online web apps. Also going from JS to Java or vice versa is not as easy as evryone thinks. The only thing the two languages have in common is the word Java in their name.



Tag(thx fkusumot) - "Yet again I completely fail to see your point..."

HD vs Wii, PC vs HD: http://www.vgchartz.com/forum/thread.php?id=93374

Why Regenerating Health is a crap game mechanic: http://gamrconnect.vgchartz.com/post.php?id=3986420

gamrReview's broken review scores: http://gamrconnect.vgchartz.com/post.php?id=4170835

 

You might want to investigate Server Side Includes (SSI). They should be supported by Apache Server and Microsoft IIS.

You can use an include container in pages like <!--#include file="header.shtml"--> where needed.



WHERE IS MY KORORINPA 3

SSI is a really bad solution... for just about anything you want to do.

I suggest looking into jquery (http://jquery.com/). I use it and a couple firefox extensions to redo vgChartz for my pleasure (adding in user/post hiding, user portrait changing, and more). It's a small, flexible, and easy to use framework.