how do I

They have: 6 posts

Joined: Feb 2000

How can I make javascript write the following html code to the browser from an external file(i.e. nav.js)?

Back Home



[Edited by Ghigman3 on 07-04-2000 at 11:47 AM]

They have: 4 posts

Joined: Apr 2000

This gets a little crazy, I had to do something like this recently. It's too bad there are only two forms of quotation marks to use in JS, and that's no doubt the problem you're running into.

Here's the way I got around it.

When you have script elements within a tag that require a single quotation ( ' ), eliminate that tag, and store the information as a variable you can call with no quotes.

For instance, in the first link,

Back Home

You're going to have to make 'Back Home' a variable (I'd call it something easily recognized like:
var backhome='Back Home' ) and then in the tag itself (in nav.js) it will become:

(that's assuming you also set up the variable blankstatus=' ' before also.)

Now you only have one kind of quotation mark in what you want to write, so you can use the standard document.write('whatever') tag without conflicting quotes.

So your nav.js file is going to look like this:

var blankstatus=' '
var backhome='Back Home'
var newstory='Here you will find a new Ghost story every month'

//and now apply your old codes, minus the scripted parts, in a document.write tag:

document.write('Back Home
')

And so on...

I hope this helped.

If you have further questions, e-mail me at [email protected]

Vincent Puglia's picture

They have: 634 posts

Joined: Dec 1999

Hi,

document.write("

They have: 6 posts

Joined: Feb 2000

I can't get any of the stuff either of you gave me.....
Could you make me somthing so I only need to fill in the blanks??

[Edited by Ghigman3 on 07-05-2000 at 07:01 PM]

Vincent Puglia's picture

They have: 634 posts

Joined: Dec 1999

Hi,

You mean like:
Danny Goodman's Javas___t Bi__e ?

or:

document.write() needs a pair of closing quotes for itself, so any quotes within those must either be single quotes or escaped quotes. You escape quotes by preceeding them with a /

var textVariable = "He said, 'something'.";
document.write(textVariable);
document.write("He said, 'something'.");
document.write("He said, /"something/".");

Or:
would you prefer I rewrite the code for you? Smiling

Vinny

[Edited by Vincent Puglia on 07-05-2000 at 08:06 PM]

Where the world once stood
the blades of grass cut me still

They have: 6 posts

Joined: Feb 2000

I was hoping you might redo the code for me since I'm not very good with javascript.

They have: 6 posts

Joined: Feb 2000

I did it!!!!!!!!!!I got it to work!!!!!!!!
Heres what I ended up with:

var txtOver1 = "Back Home";
var txtOver2 = "Here you will find a new Ghost story every month";
var txtOver3 = "Here you will find a links to other ghost sites";
var txtOver4 = "Here you will find a weekly poll";
var txtOver5 = "Ghost attractions of America";
var txtOut = " ";
document.write('Back Home')

Vincent Puglia's picture

They have: 634 posts

Joined: Dec 1999

Hi,

Now, aren't you glad I didn't write it for you? Smiling
'Cause if I (or anyone else) did, you would have learned nothing and been back with a similiar problem at some future date. Now...you can code (some, maybe, but code nonetheless)
Congrats! Smiling

Vinny

Where the world once stood
the blades of grass cut me still

They have: 6 posts

Joined: Feb 2000

Well I would like to thank you for your help. I look forword to coming here in the future for help.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.