Jump to content

Help with a welcome cookie for my site


knimbus

Recommended Posts

Hi, I am very new too Javascript and I started reading the tutorial on this site... I really like the idea of the welcome cookie so I copied the code into notepad and edited it so as instead of it displaying as

alert("Welcome back '+username+'!")

(I have not included curly brackets for if statement) it would display as

document.write("Welcome back '+username+'!")

I hoped that this would make the message appear in the paragraph I wrote the html into (I am using the freewebs sitebuilder) but it meant that after I set the cookie i would get the message from the site, but on a blank page. Can someone point me in the right direction please?Also, I can't try it now (unless i cleared my cookies) but I am sure my alert box to set the cookie looked different, but maybe thats because I was using I.E to test.

Link to comment
Share on other sites

Error: getElementById is not definedSource File: http://knimbus.com/Line: 92well, thats the error...the line I put in instead of the alert line wasgetElementById('fw-paragraph').innerHTML="Welcome back " + username + "!";As I said i am new to all of this so if someone would like to use the link in the error to check the paragraph id for me i would be thankful.

Link to comment
Share on other sites

well, lets say I'm fluent in some parts of javascript. :) this error isn't one of those parts. I've had that error before, and I couldn't figure out how to fix it. (by the way, a lot of my "fluency" is from things I've tried, and believe me, I've tried a lot on this one.)I'll see if I can find something...LG*edits signature*

Link to comment
Share on other sites

hi, thanks for that, but its still not working :-(... I think i may have gotton the paragraph id wrong. Could you please check it for me? It's the paragraph(currently blank) above the embede flash and below the navbar.

Link to comment
Share on other sites

ok, I think I know what I am doing know, but I need to know something, how do I edit the id names of certain elements because at the minute, there are no id names for any of the elements.oh, and yes, the one that has the time in it sometimes, I put that in just to check that code was working ok.

Link to comment
Share on other sites

ok, on your page it says getElementById('fw-parac')instead of getElementById('fw-paragraph')change that and all should work. :) whoa wait a minute, you have the class set to that, not the id. change that too.LGEdit:just add this attribute: id="fw-paragraph"

Link to comment
Share on other sites

Do you mean in the DOM inspecter? and if so do you mean to add new 'blah' and put in id= and then in value put in 'fw-paragraph'?P.S I hate being a newbie in these things...P.P.S don't worry, we'll get your postcount up past 300 in this topic yet :)

Link to comment
Share on other sites

groaaan....In I.E I get an error now, In FF I enter my name, refresh the page and... nothing, still an empty paragraph, after the DOM inspecter, if I add an attribute, it doesn't appear in the bottom left pane, but the id name does appear. but anyway, I am still getting the I.E error and the FF blank paragraph. Is there anyway for me to like, give control to you or something and you can try?(haven't got a clue what i'm talking about when i say control, lol)

Link to comment
Share on other sites

ok, I don't see any ID's on your page...I don't think you could give me control unless you gave me you ftp password :) I don't even really know how to do that anyway...I'll play around with the code and see what I can do.P.S. did you build that site from scratch? not to be rude, but the code is all messed up...P.P.S. yay! 300 posts! :) LG

Link to comment
Share on other sites

Whyyyyyy??????still nothing happens when I reload the homepage after entering my name in the box...The cookie is working alright because in the DOM inspectore I changed from nodes to JS objects and saw the cookie and it had the right info.why is it not displaying?try it urself?

Link to comment
Share on other sites

ok, I "stole" your code onto my computer and added the id, and it works great.change your div from this:<div class="fw-paragraph">to this:<div class="fw-paragraph" id="fw-paragraph">LGEdit: you still don't have the id, edit by hand if posible...

Link to comment
Share on other sites

time to get some stuff sorted herewhat do you mean "by hand"when I put in the id value it doesn't stay, next time I open the inspector up there is no idwhat are you talking about "Div class" in the inspector it is just "class"I am srry if i am making you lose your patience but no matter what code I start to learn there are alway some problems...in VB.NET I couldn't do arrays or randomsin Actionscript, my buttons and cursor wouldnt work etc...basically, can you give me a step by step?

Link to comment
Share on other sites

time to get some stuff sorted herewhat do you mean "by hand"when I put in the id value it doesn't stay, next time I open the inspector up there is no idwhat are you talking about "Div class" in the inspector it is just "class"I am srry if i am making you lose your patience but no matter what code I start to learn there are alway some problems...in VB.NET I couldn't do arrays or randomsin Actionscript, my buttons and cursor wouldnt work etc...basically, can you give me a step by step?

by hand=open in good old NOTEPADdiv class= the div's class1.open your page in notepad, not your other fancy programs2.scroll down until you see a <div class="fw-paragraph"> that has the javascript underneath it.3. change it to <div class="fw-paragraph" id="fw-paragraph">4. save it.5. it works! (celebrate :) )p.s. i'm ok, I am now the 8th top poster instead of 9th... :) LG
Link to comment
Share on other sites

well, how does it open in the other program? I'm not familiar with freewebs or any other host, but if you just open the page where you have access, then right click on the page, and click view source. or, actually, you can just click the edit button in IE.LG

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...