One more Javascript question

Miscellaneous Forums/General Discussion/One more Javascript question

I have another problem with javascript. I'm trying:

document.write('

line1 text
line2 text
...

');

But javascript takes the end of the line as command limiter (although some browsers still force the semicolon, some don't AFAIK), so it didn't work, an arror msg says "unterminated string literal".

Is there a way to write multiple lines with one document.write?.

What I'm trying to do is to use an include file in a way that doesn't require a running webserver like the following methods:

Pearl cgi include
PHP include
ssi serverside include

I also don't want to use "document.write" for every line. As well as frames or iframes.

Any ideas?

Ok, currently I'm trying to use the <object data="url"> HTML tag. This would really be a perfect simple way. It works in Opera and msie, not in Firefox so far...

Probably I need to use a certain mime type, I tried:

<object type="text/html" data="include_me.html"></object>

as mentioned here: http://www.rfc-editor.org/rfc/rfc2854.txt

No success this way on Firefox. EDIT: I would also rather not use OBJECT since all browsers are providing some kind of canvas for objects with a width and height, msie even forces width and height parameters. But what I needed was a simple html code include.

I just went through a JavaScript manual some days ago
I got the impression that JavaScripyt could be the ideal script language for a game engine
It makes use of prefabricated object, the original use are for web pages of coures, but it could be easly adapted for the entities in a game
In other words thanks to JavScript you might have a OOP like tool without the intricacies of a true OOP
What do you think ?

I've read this twice now and I'm still not 100% sure what it is you're trying to achieve, but to do line breaks in document.write, use \n

*EDIT*
or
var out = "test\n<br />";
out += "test\n<br />";
out += "test\n<br />";
out += "test\n<br />";
document.write(out);


Best idea is to build the line by adding strings to a variable, and then write out the variable. More or less the way Perturbatio does it above (but I gather you want a single line rather than multiple lines).

Thanks. What I'm trying to do is the same as in PHP, eg:
<#include "menu.inc">

I would also accept some javascript on the first and on the last line of menu.inc, but not on every line.

Well, I think I'll use document.write(string); for every line. After all it's not so bad.

I'm not entirely sure what you're trying to achieve here, JFK. If you simply want to include a block of javascript from a local or remote file then just use:-

<script language="Javascript" src="http://www.wherever.com/js_file.js"></script>


with the code you want to include in the file 'js_file.js'. The path used withe the src attribute can be relative or absolute.

I'm not entirely sure what you're trying to achieve here, JFK


He's trying to create a dynamic menu without server side processing.