TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,973
  • Latest: NonStop
Stats
  • Total Posts: 196,231
  • Total Topics: 21,353
  • Online today: 651
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 386
  • Total: 386

Problem inserting javascript into TP block

Started by buildingblocks, April 06, 2009, 02:46:16 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

buildingblocks

Hi all

I'm working with a new install of SMF upgraded to SMF 1.1.8. The only package installed is TinyPortal v1.0 beta 3.

I'm trying to get a scrolling banner javascript working in an added html & javascript TP block.

I'm pasting the javascript into the html editor (not the wysiwyg). I save and then refresh the forum window. The banners are not showing up. View source shows the code is there, but it's been changed.

ex:

from this

leftrightslide[0]='<a href=

to this

leftrightslide[0]='&amp;lt;a href=

The code appears to be working correctly when it's saved in an html page and opened in a browser.


I read another thread where Bloc suggested updating whizzywig.js to the TP beta 4 version whizzywig.js

I did that but the problem persists.

Straight html works fine in the TP block but not this javascript.

I'm new to SMF, TP and up till now never did much with javascript so maybe I'm not doing something right?

Thanks for any help.

JPDeni

It's hard to know for sure, since you haven't posted the code within the code tags, but a suggestion is that, now that you've saved it, delete everything in the block and paste it back in again and save it. I've occasionally had problems with things when I first put them into an article or block.

If you're not using the editor, then whizzywig wouldn't have any effect.

buildingblocks

>>If you're not using the editor, then whizzywig wouldn't have any effect.<<

:-) That does make sense.

I've tried deleting and paste/save again, but made no difference. The code I'm using is rather long for posting. I found a free to use shorter script I tried and the same thing happens. The code gets re-written.

Here's the code I tried:


<ilayer id="l1">
<layer id="l2">
<div id="l1">
<div id="l3" style="position:relative">
</div>
</div>
</layer>
</ilayer>
<script language="JavaScript">
<!--

// ***********************************************
// AUTHOR: WWW.CGISCRIPT.NET, LLC
// URL: http://www.cgiscript.net
// Use the script, just leave this message intact.
// Download your FREE CGI/Perl Scripts today!
// ( http://www.cgiscript.net/scripts.htm )
// ***********************************************

var bannerArray = new Array();
var myCount=0;
// Banner Code Assignment
bannerArray[0] = "<A HREF=\"http://www.aceinstall.com\"><IMG SRC=\"http://www.aceinstall.com/banners/ban-468x60.gif\" border=\"0\" width=\"468\" height=\"60\"></A>";
bannerArray[1] = "<A HREF=\"http://www.cgiscript.net\"><IMG SRC=\"http://www.cgiscript.net/banners/ban-468x60.gif\" border=\"0\" width=\"468\" height=\"60\"></A>";
bannerArray[2] = "<A HREF=\"http://www.aceinstall.com\"><IMG SRC=\"http://www.aceinstall.com/banners/aniban-468x60.gif\" border=\"0\" width=\"468\" height=\"60\"></A>";

bannerRotate();

function bannerRotate() {

if(myCount > bannerArray.length-1){myCount=0;}

// Write out rotation
if (document.all){ // it is IE
document.all.l3.innerHTML=bannerArray[myCount];
}

else if (document.layers){ // it is NN

document.layers.l1.document.layers.l2.document.open();
document.layers.l1.document.layers.l2.document.write(bannerArray[myCount]);
document.layers.l1.document.layers.l2.document.close();
}
setTimeout("bannerRotate()", 3000);
myCount++;
}
// -->
</script>


Here's the code after it gets saved in my TP Block:

<ilayer id="l1">
</ilayer>
<script language="JavaScript">
&amp;lt;!--
// ***********************************************
// AUTHOR: WWW.CGISCRIPT.NET, LLC
// URL: http://www.cgiscript.net
// Use the script, just leave this message intact.
// Download your FREE CGI/Perl Scripts today!
// ( http://www.cgiscript.net/scripts.htm )
// ***********************************************
var bannerArray = new Array();
var myCount=0;
// Banner Code Assignment
bannerArray[0] = "&amp;lt;A HREF=\"http://www.aceinstall.com\"&amp;gt;&amp;lt;IMG SRC=\"http://www.aceinstall.com/banners/ban-468x60.gif\" border=\"0\" width=\"468\" height=\"60\"&amp;gt;&amp;lt;/A&amp;gt;";
bannerArray[1] = "&amp;lt;A HREF=\"http://www.cgiscript.net\"&amp;gt;&amp;lt;IMG SRC=\"http://www.cgiscript.net/banners/ban-468x60.gif\" border=\"0\" width=\"468\" height=\"60\"&amp;gt;&amp;lt;/A&amp;gt;";
bannerArray[2] = "&amp;lt;A HREF=\"http://www.aceinstall.com\"&amp;gt;&amp;lt;IMG SRC=\"http://www.aceinstall.com/banners/aniban-468x60.gif\" border=\"0\" width=\"468\" height=\"60\"&amp;gt;&amp;lt;/A&amp;gt;";
bannerRotate();
function bannerRotate() {
if(myCount &amp;gt; bannerArray.length-1){myCount=0;}
// Write out rotation
if (document.all){ // it is IE
document.all.l3.innerHTML=bannerArray[myCount];
}
else if (document.layers){ // it is NN
document.layers.l1.document.layers.l2.document.open();
document.layers.l1.document.layers.l2.document.write(bannerArray[myCount]);
document.layers.l1.document.layers.l2.document.close();
}
setTimeout("bannerRotate()", 3000);
myCount++;
}
// --&amp;gt;
</script>




JPDeni

I pasted your code into a javascript + html block (using v1.0 beta 4, which you don't have yet). I do have the editor active, but I clicked the <> button to access the source code. I pasted in the script and saved it.

I didn't get any rotating banners -- I didn't get anything at all -- but the source code shows that the javascript is there.

Then I started up my v1.0 beta 3, to see if there was a difference. I don't have whizzywig on it at all, and I pasted the javascript in. Same thing. I didn't get any result, but the source code shows the javascript.

So... If you're not using whizzywig, just delete it from your forum via FTP or another file manager. Then give it another try. :)

buildingblocks

Thanks for your effort JPDeni

Does your source code show the javascript as it should be or did it get re-written?

Also

I found that initially making a php block, saving the code and then changing to an html/javascript block works as mentioned by Renegd98 in this post

http://www.tinyportal.net/index.php/topic,28812.0.html

but is not practical for frequent edits.

I'll try removing the whizzywig. Would I just delete the file or what?

buildingblocks

another option would be to save it as a php block...change it to an html/javascript block to get the banners working and then make all future edits via cpanel. That would work for me. Would you know which file to access to see if that works?

JPDeni

As it should be. See my test site here. It's in the block on the left labeled "javascript test."

I just deleted the whizzywig folder altogether. Didn't seem to cause any problems. :)

I'm not sure about your other question. The code is stored in the database.

buildingblocks

I deleted the whizzywig folder and that took care of the problem. I don't need the wysiwyg editor either.

What I meant by "make all future edits via cpanel." is I would have edited the file that handled the TP block manually in cpanel if that would have worked. But it's not necessary now anyway.

Thanks for helping JPDeni

This website is proudly hosted on Crocweb Cloud Website Hosting.