PDA

View Full Version : BBCode only works in single post, not full thread


Sovereign123
02-05-2012, 04:17 PM
I've been trying to get Syntax Highlighting to work on my board so I added BB Code utilizing google's prettify.

As we can see it works here: http://snpr.cm/Mhtsv5.png
[Link looks like: http://myforum.com/forums/showthread.php?557-Coding-Convention-amp-Guidelines&p=3054#post3054 ]

And it doesn't work here: http://snpr.cm/OE9Y3F.png
[Link: http://myforum.com/forums/showthread.php?557-Coding-Convention-amp-Guidelines ]


My BB Code is this:
<link href="http://myforum.com/prettify/src/prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="http://myforum.com/prettify/src/prettify.js"></script>

<script type="text/javascript">
var theonload = window.onload;
window.onload = function(){
theonload();
prettyPrint();
}
</script>
<pre class="prettyprint">
{param}
</pre>

Any ideas what the issue could be with that?

kh99
02-05-2012, 04:51 PM
I'm not sure if this will make any difference, but maybe try putting this in headinclude:

<vb:if condition="THIS_SCRIPT == 'showthread'">
<link href="http://myforum.com/prettify/src/prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="http://myforum.com/prettify/src/prettify.js"></script>

<script type="text/javascript">
var theonload = window.onload;
window.onload = function(){
theonload();
prettyPrint();
}
</script>
</vb:if>


Then just make the bbcode:

<pre class="prettyprint">
{param}
</pre>


That has the disadvantage of always loading the prettyprint stuff whether or not it's used, but this way it's only loaded once.

If that doesn't work, if you could post a link to your threads that might help in figuring out (although I suppose you would have done that if you didn't want to keep it private).

Sovereign123
02-05-2012, 06:22 PM
Yeah that solution didn't work out. I don't mind letting you check it, it's in a private section which is why I didn't give out the link itself.

I made an account you can view it from, I'll PM it to you.

Thanks a lot for your time!

kh99
02-05-2012, 06:38 PM
Try using:

<script type="text/javascript">
var theonload = window.onload;
window.onload = function(){
if (theonload) theonload();
prettyPrint();
}
</script>


the part in red is added. The fact that theonload isn't a function is causing an error on the page that doesn't work, but I don't know why it's not causing an error on both pages.

Sovereign123
02-06-2012, 04:36 AM
Thank you very very much, that fixed the issue right up. Only one tag works per page, but I can live with that hahaha.

EDIT: Nope, managed to fix that too!


<script type="text/javascript">
if (window.onload = " ")
{
var theonload = window.onload;
window.onload = function(){
if (theonload) theonload();
prettyPrint();
}
}


That's what perfected it!