The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Unable to put a Javascript in the templates

2 posters

Go down

Solved Unable to put a Javascript in the templates

Post by Neoroify 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
avatar
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 October 12th 2010, 8:22 pm

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


Back to top Go down

Solved Re: Unable to put a Javascript in the templates

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

It's still not appearing.. errr.... that's not good :o
avatar
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 October 12th 2010, 8:34 pm

Can i see the link for the code xD?
avatar
Guest
Guest


Back to top Go down

Solved Re: Unable to put a Javascript in the templates

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

avatar
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 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!
avatar
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 October 12th 2010, 8:44 pm

Good but it worked for me Razz
avatar
Guest
Guest


Back to top Go down

Solved Re: Unable to put a Javascript in the templates

Post by Neoroify 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
avatar
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 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.
Unable to put a Javascript in the templates Locked1Unable to put a Javascript in the templates Lock2 RoNo
Unable to put a Javascript in the templates Bullet_blue2 General rules
Unable to put a Javascript in the templates Bullet_blue2 Tricks & Tips
Unable to put a Javascript in the templates Bullet_blue2 FAQ listing
Unable to put a Javascript in the templates Bullet_blue2 For founders who lost their passwords
Unable to put a Javascript in the templates Bullet_blue2 About support requests by PM
Unable to put a Javascript in the templates Bullet_blue2 Announcements & Updates
RoNo
RoNo
Active Poster

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

http://bf2mercenaries.forumotion.com/

Back to top Go down

Back to top


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