The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Unable to put a Javascript in the templates

View previous topic View next topic Go down

Solved Unable to put a Javascript in the templates

Post by Neoroify on October 12th 2010, 8:12 pm

Greetings, I've been trying to put a Javascript which is a dynamically changing banner w/ links, just like Advertisement Rotation or so.. But fortunately i can not do so, because somehow the "banners" are not showing up.

The javascript should be like that:
Code:
<script>
var img_width = "468";
var img_height = "60";
var img_title = "Click Here";


var ad=new Array()
ad[0]='xxxxxx';
ad[1]='xxxxx';
ad[2]='hxxxx';

var links=new Array()
links[0]='http://ixxx';
links[1]='http://axxxxxxxx5';
links[2]='http://ixxxxf=xxxxox';

var xy=Math.floor(Math.random()*ad.length);
document.write('<a href="'+links[xy]+'" target="_blank"><img src="'+ad[xy]+'" width="'+img_width+'" height="'+img_height+'" alt="'+img_title+'"></a>');
</script>

But it's not shown in my forums.., the "xxxxx" and stuff are replacement just not to advertise here, but the code is actually correct!


Last edited by Neoroify on October 12th 2010, 8:44 pm; edited 1 time in total

Neoroify
Forumember

Posts : 99
Reputation : 0
Language : English

Back to top Go down

Solved Re: Unable to put a Javascript in the templates

Post by Guest on October 12th 2010, 8:22 pm

Ehm,, let's change this "<script>" to "<script type="text/javascript">" (:

Guest
Guest


Back to top Go down

Solved Re: Unable to put a Javascript in the templates

Post by Neoroify on October 12th 2010, 8:25 pm

It's still not appearing.. errr.... that's not good :o

Neoroify
Forumember

Posts : 99
Reputation : 0
Language : English

Back to top Go down

Solved Re: Unable to put a Javascript in the templates

Post by Guest on October 12th 2010, 8:34 pm

Can i see the link for the code xD?

Guest
Guest


Back to top Go down

Solved Re: Unable to put a Javascript in the templates

Post by Neoroify on October 12th 2010, 8:38 pm


Neoroify
Forumember

Posts : 99
Reputation : 0
Language : English

Back to top Go down

Solved Re: Unable to put a Javascript in the templates

Post by Neoroify on October 12th 2010, 8:43 pm

Err, you know what, never mind about that, I've found an other alternative to solve the problem, I used a banner rotation generator. so, probably solved!

Neoroify
Forumember

Posts : 99
Reputation : 0
Language : English

Back to top Go down

Solved Re: Unable to put a Javascript in the templates

Post by Guest on October 12th 2010, 8:44 pm

Good but it worked for me Razz

Guest
Guest


Back to top Go down

Solved Re: Unable to put a Javascript in the templates

Post by Neoroify on October 12th 2010, 8:51 pm

Yeah that's good it worked for you, but the one i found is.. lol.. returning to my homepage, tho the links are linking to a designated webpage -.-

The code is working properly as previewed at the place of creation, but at my forum, it is not cycling and is leading to my homepage Confused

http://forum.neoroify.eu/ You can see it yourself.. err

Neoroify
Forumember

Posts : 99
Reputation : 0
Language : English

Back to top Go down

Solved Re: Unable to put a Javascript in the templates

Post by RoNo on October 12th 2010, 9:54 pm

You can link scripts so they function properly
when used in templates and widgets.

Create an Html page with the code.
(Example title for the page: code1_js
Code:
var img_width = "468";
var img_height = "60";
var img_title = "Click Here";


var ad=new Array()
ad[0]='xxxxxx';
ad[1]='xxxxx';
ad[2]='hxxxx';

var links=new Array()
links[0]='http://ixxx';
links[1]='http://axxxxxxxx5';
links[2]='http://ixxxxf=xxxxox';

var xy=Math.floor(Math.random()*ad.length);
document.write('<a href="'+links[xy]+'" target="_blank"><img src="'+ad[xy]+'" width="'+img_width+'" height="'+img_height+'" alt="'+img_title+'"></a>');
Save code only on the page, no tags such as: <script> or titles.


Get the page Url from Html pages management & link it like this
Code:
<script src="http:YOUR HTML/SCRIPT PAGE.code1_js.htm" type="text/javascript"></script>

You can also use a site like yourjavascript.com to link scripts.
I use yourjavascript.com for scripts that contain dollar signs ($)
since that character is converted to: &#36 ; when it's saved on
Html pages or in widgets... the end result being a corrupt script.



Since an alternative has been found
to solve the issue, this topic is closed.
RoNo
General rules
Tricks & Tips
FAQ listing
For founders who lost their passwords
About support requests by PM
Announcements & Updates

RoNo
Active Poster

Male Posts : 1270
Reputation : 135
Language : English
Location : Laguna Beach, California

http://bf2mercenaries.forumotion.com/

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum