inherit
141494
0
Sept 20, 2019 9:07:14 GMT -8
Andrea
wow it's been a while...
3,388
June 2009
lookitsandrea
|
Post by Andrea on Jun 22, 2010 15:35:53 GMT -8
So, I am attempting to teach myself javascript. It's not working too well. Anyway, this doesn't work, obviously, so I'm wondering if it's a simple change or a major redo is necessary... (I was looking at other PM codes to get an idea for this) <script> /* TPBS PM */ var user = pb_displayname var guestMessage = "<a href="http://top-pb-sites.proboards.com/index.cgi?action=login"><img src="http://i50.tinypic.com/nqodx1.png" border="0"></a> var pmNew = = '<a href="http://top-pb-sites.proboards.com/index.cgi?action=pm"><img src="http://i49.tinypic.com/1fxw9d.png" border="0"></a>' var memberMessage = '<a href="http://top-pb-sites.proboards.com/index.cgi?action=pm"><img src="http://i48.tinypic.com/etwojo.png" border="0"></a>' pmCell.innerHTML = memberMessage if(get[3].innerHTML.match(/Guest/i)){ pmCell.innerHTML = '<center>'+guestMessage+'</center>' } </script>
|
|
#00AF33
14306
0
1
Sept 8, 2023 8:54:17 GMT -8
Jordan
What is truth?
11,838
October 2003
jab2
|
Post by Jordan on Jun 22, 2010 16:39:31 GMT -8
<script> /* TPBS PM */ var user = pb_displayname; var guestMessage = '<a href="http://top-pb-sites.proboards.com/index.cgi?action=login"><img src="http://i50.tinypic.com/nqodx1.png" border="0"></a>'; var pmNew = '<a href="http://top-pb-sites.proboards.com/index.cgi?action=pm"><img src="http://i49.tinypic.com/1fxw9d.png" border="0"></a>'; var memberMessage = '<a href="http://top-pb-sites.proboards.com/index.cgi?action=pm"><img src="http://i48.tinypic.com/etwojo.png" border="0"></a>'; pmCell.innerHTML = memberMessage; if(get[3].innerHTML.match(/Guest/i)){ pmCell.innerHTML = '<center>'+guestMessage+'</center>'; } </script>
The first line is unnecessary because you are just copying a variable that isn't going to change.
You also have some incorrect syntax on the third line (= =), and you are missing the semi-colons which mark the end of a line.
Also, pmCell and get are not declared anywhere, so the JS engine doesn't know what they represent. You need to use the document.getElementsByTagName() function to grab the element you want to insert the data into.
|
|
inherit
97216
0
Nov 26, 2024 13:53:14 GMT -8
Bennett 🚀
Formerly iPokemon.
3,622
January 2007
catattack
iPokemon's Mini-Profile
|
Post by Bennett 🚀 on Jun 22, 2010 16:51:24 GMT -8
And you should always start with <script type="text/javascript"><!-- and end with //--></script> EDIT: And you aren't using the variable user yet, just so you know
|
|
inherit
100824
0
May 13, 2012 5:37:49 GMT -8
Michael
14,585
March 2007
wrighty
|
Post by Michael on Jun 23, 2010 12:28:26 GMT -8
And you should always start with <script type="text/javascript"><!-- and end with //--></script> EDIT: And you aren't using the variable user yet, just so you know You don't have to ... the simple: <script></script> tags suffice!
|
|
inherit
134992
0
May 26, 2012 2:38:57 GMT -8
SubDevo
Creator of LSD...
3,861
December 2008
subdevo
|
Post by SubDevo on Jun 23, 2010 13:44:59 GMT -8
Of course you don't have to do it... lol It is just good practice to do that. Keeps those older browsers happy... And it certainly doesn't hurt to start and end that way either.
|
|
inherit
77753
0
Jul 18, 2024 12:23:50 GMT -8
Bob
2,623
April 2006
bobbyhensley
|
Post by Bob on Jun 23, 2010 15:01:50 GMT -8
And you should always start with <script type="text/javascript"><!-- and end with //--></script> EDIT: And you aren't using the variable user yet, just so you know There really is absolutely no reason to comment scripts out any longer. The oldest brower still in common use is IE6, which handles JavaScript properly as it is. The only commenting that should be taking place (excluding the script's comments) is designating CDATA (character data that isn't markup). For example: <script type="text/javascript"> // <![CDATA[
alert ("Hello world!");
// ]]> </script>
<style type="text/css"> /* <![CDATA[ */
body { background-color: #000; }
/* ]]> */ </style> But the common "<!-- //-->" inside scripts is outdated.
|
|
inherit
100824
0
May 13, 2012 5:37:49 GMT -8
Michael
14,585
March 2007
wrighty
|
Post by Michael on Jun 24, 2010 2:26:42 GMT -8
And you should always start with <script type="text/javascript"><!-- and end with //--></script> EDIT: And you aren't using the variable user yet, just so you know There really is absolutely no reason to comment scripts out any longer. The oldest brower still in common use is IE6, which handles JavaScript properly as it is. The only commenting that should be taking place (excluding the script's comments) is designating CDATA (character data that isn't markup). For example: <script type="text/javascript"> // <![CDATA[
alert ("Hello world!");
// ]]> </script>
<style type="text/css"> /* <![CDATA[ */
body { background-color: #000; }
/* ]]> */ </style> But the common "<!-- //-->" inside scripts is outdated. Isn't that only neede in some cases though? Not all? Depends on the character encoding doesn't it? Orrr is it the DocType? *shrugs*
|
|
inherit
134992
0
May 26, 2012 2:38:57 GMT -8
SubDevo
Creator of LSD...
3,861
December 2008
subdevo
|
Post by SubDevo on Jun 24, 2010 2:32:52 GMT -8
I tend to err on the side of caution. I will still include "<!-- //-->" in all my scripts...
|
|
inherit
77753
0
Jul 18, 2024 12:23:50 GMT -8
Bob
2,623
April 2006
bobbyhensley
|
Post by Bob on Jun 24, 2010 3:36:06 GMT -8
I tend to err on the side of caution. I will still include "<!-- //-->" in all my scripts... And I'm sure the zero people using the likes of IE1 and IE2 appreciate your kindness. However instead of catering to them maybe you should begin screwing them over. Perhaps they'll get the memo that their browser from 1995 doesn't cut it anymore. In the mean time however your comments may very well end up affecting modern/future browsers. Strictly adhering to W3C standards, browsers are allowed to remove the contents of comments inside XML documents. And while this isn't the common practice right now, what's to say a future release of Firefox or IE won't take the W3C up on the chance to render less code? Isn't that only neede in some cases though? Not all? Depends on the character encoding doesn't it? Orrr is it the DocType? *shrugs* Well I can tell you that you'd want to declare your script as CDATA in any XML documents (so XHTML) but I'm not 100% certain where HTML stands. SGML (what both HTML and XML are based off of) recognizes character data, so I suppose it may be proper to include the definition within HTML documents as well. Which makes sense when you think about it: character data is simply a portion of the code that is to not be rendered by the DOM. It can actually be used anywhere in the document to make sure the contents within it don't end up parsed.
|
|
inherit
130228
0
Jul 11, 2024 19:19:59 GMT -8
Charles Stover
1,731
August 2008
gamechief
|
Post by Charles Stover on Jun 24, 2010 9:52:36 GMT -8
CDATA is for XHTML. I haven't heard of using it in <style>, though. Just JS. Makes sense that you'd use it in CSS too; I just haven't heard of that.
|
|
inherit
97216
0
Nov 26, 2024 13:53:14 GMT -8
Bennett 🚀
Formerly iPokemon.
3,622
January 2007
catattack
iPokemon's Mini-Profile
|
Post by Bennett 🚀 on Jun 24, 2010 14:26:26 GMT -8
Whenever I use <!-- //--> in CSS, it breaks the coding x.x
|
|
#00AF33
14306
0
1
Sept 8, 2023 8:54:17 GMT -8
Jordan
What is truth?
11,838
October 2003
jab2
|
Post by Jordan on Jun 24, 2010 16:07:06 GMT -8
Whenever I use <!-- //--> in CSS, it breaks the coding x.x That's because you're not supposed to include // in CSS. <!-- -->
|
|
inherit
97216
0
Nov 26, 2024 13:53:14 GMT -8
Bennett 🚀
Formerly iPokemon.
3,622
January 2007
catattack
iPokemon's Mini-Profile
|
Post by Bennett 🚀 on Jun 24, 2010 18:41:21 GMT -8
Lol, no wonder. I was thinking that was kind of fishy..
|
|
inherit
130228
0
Jul 11, 2024 19:19:59 GMT -8
Charles Stover
1,731
August 2008
gamechief
|
Post by Charles Stover on Jun 28, 2010 21:18:24 GMT -8
CSS doesn't support single-line comments, hence // breaks it.
I'd still like if someone could expand upon using CDATA in CSS. >_<
|
|
inherit
77753
0
Jul 18, 2024 12:23:50 GMT -8
Bob
2,623
April 2006
bobbyhensley
|
Post by Bob on Jun 28, 2010 22:30:07 GMT -8
CSS doesn't support single-line comments, hence // breaks it. I'd still like if someone could expand upon using CDATA in CSS. >_< The same reason you use it on scripts: to declare the content as inconsequential to the DOM. CSS isn't markup thus it shouldn't sit in an SGML/XML document as such. Declaring the content of the stylesheet as character data does just that.
|
|