01-09-07, 12:02 AM
Newbie Coder
Join Date: Jan 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
mBanner
Hi, I'm newbie here and in javascript, I have a problem please help me.
I used mBanner.js for my banner system until MS fix IE: display "Click to activate and use this control" on Flash banner.
I found this javascript to display Flash banner alone is ok.
When I modifies mBanner.js code which display Flash banner like above function, it not work.
Code:
// BANNER OBJECT
function Banner(objName)
{
this.obj = objName;
this.aNodes = [];
this.currentBanner =Math.floor(Math.random()*3);
};
// ADD NEW BANNER
Banner.prototype.add = function(bannerType, bannerPath, bannerDuration, height, width, hyperlink) {
this.aNodes[this.aNodes.length] = new Node(this.obj +"_"+ this.aNodes.length, bannerType, bannerPath, bannerDuration, height, width, hyperlink);
};
// Node object
function Node(name, bannerType, bannerPath, bannerDuration, height, width, hyperlink) {
this.name = name;
this.bannerType = bannerType;
this.bannerPath = bannerPath;
this.bannerDuration = bannerDuration;
this.height = height
this.width = width;
this.hyperlink= hyperlink;
// alert (name +"|" + bannerType +"|" + bannerPath +"|" + bannerDuration +"|" + height +"|" + width + "|" + hyperlink);
};
// Outputs the banner to the page
Banner.prototype.toString = function() {
var str = ""
//alert(this.aNodes.length);
for (var iCtr=0; iCtr < this.aNodes.length; iCtr++) //old: iCtr=0
{
//alert(pos);
str = str + '<span name="'+this.aNodes[iCtr].name+'" '
str = str + 'id="'+this.aNodes[iCtr].name+'" ';
str = str + 'class="m_banner_hide" ';
str = str + 'bgcolor="#FFFCDA" '; // CHANGE BANNER COLOR HERE
str = str + 'align="center" ';
str = str + 'valign="top" >\n';
if (this.aNodes[iCtr].hyperlink != ""){
str = str + '<a href="'+this.aNodes[iCtr].hyperlink+'" target="_blank">';
}
if ( this.aNodes[iCtr].bannerType == "FLASH" ){
str=str+ '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" '
str=str+ 'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" '
str=str+ 'width="'+this.aNodes[iCtr].width+'" '
str=str+ 'height="'+this.aNodes[iCtr].height+'" '
str=str+ 'id="bnr_'+this.aNodes[iCtr].name+'" align="middle" VIEWASTEXT> '
str=str+ '<param name="allowScriptAccess" value="always" />'
str=str+ '<param name="movie" value="'+this.aNodes[iCtr].bannerPath+'" />'
str=str+ 'param name="FlashVars" value="'+vars+'" />'
str=str+ '<param name="wmode" value="transparent" />'
str=str+ '<param name="menu" value="false" />'
str=str+ '<param name="quality" value="high" />'
str=str+ '<embed src="'+this.aNodes[iCtr].bannerPath+'" wmode="transparent" menu="false" quality="high" width="'+this.aNodes[iCtr].width+'" height="'+this.aNodes[iCtr].height+'" name="bnr_'+this.aNodes[iCtr].name+'" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
str=str+ '</embed></object>'
}
else if ( this.aNodes[iCtr].bannerType == "IMAGE" ){
str = str + '<img src="'+this.aNodes[iCtr].bannerPath+'" ';
str = str + 'border="0" ';
str = str + 'height="'+this.aNodes[iCtr].height+'" ';
str = str + 'width="'+this.aNodes[iCtr].width+'">';
}
if (this.aNodes[iCtr].hyperlink != ""){
str = str + '</a>';
}
str += '</span>';
}
return str;
};
// START THE BANNER ROTATION
Banner.prototype.start = function(){
this.changeBanner();
var thisBannerObj = this.obj;
// CURRENT BANNER IS ALREADY INCREMENTED IN changeBanner() FUNCTION
setTimeout(thisBannerObj+".start()", this.aNodes[this.currentBanner].bannerDuration * 1000);
}
// CHANGE BANNER
Banner.prototype.changeBanner = function(){
var thisBanner;
var prevBanner = -1;
if (this.currentBanner>this.aNodes.length-1)
{
this.currentBanner=0;
}
if (this.currentBanner < this.aNodes.length ){
thisBanner = this.currentBanner;
if (this.aNodes.length > 1){
if ( thisBanner > 0 ){
prevBanner = thisBanner - 1;
}else{
prevBanner = this.aNodes.length-1;
}
}
if (this.currentBanner < this.aNodes.length - 1){
this.currentBanner = this.currentBanner + 1;
}else{
this.currentBanner = 0;
}
}
if (prevBanner >= 0){
document.getElementById(this.aNodes[prevBanner].name).className = "m_banner_hide";
}
document.getElementById(this.aNodes[thisBanner].name).className = "m_banner_show";
}
How can I fix it ? Help me.
Thank a lot
01-19-07, 05:15 PM
Newbie Coder
Join Date: Jan 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
I am facing the some problem with the original mbanner script plus the link over a flash banner is not working also.
Any help on this community ???
01-19-07, 06:58 PM
Community VIP
Join Date: Jan 2007
Location: Belgium
Posts: 584
Thanks: 0
Thanked 0 Times in 0 Posts
I can't really help, but there exists an add-on for FireFox called "FlashBlock". It replaces any flash thingy with a button you can click to show the flash animation. Perhaps you can look up that add-on, and see how it works. It normally uses Javascript, so it should be helpful.
__________________
Jack Bauer makes Chuck Norris cry
01-20-07, 03:25 AM
Newbie Coder
Join Date: Jan 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
I solved my problem, just write the string out instead of returning
to arturex: put the link inside the flash using Action Script ( using getURL )
01-20-07, 03:11 PM
Newbie Coder
Join Date: Jan 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Hi Raven80,
thanks for the getURL tip.
pls post the complete script with the modification. I am not getting sucess ...
01-22-07, 02:26 AM
Newbie Coder
Join Date: Jan 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Here's the complete file mBanner.js with modification.
Code:
///////////////////////////////////
// File Name: mBanner.js //
// By: Manish Kumar Namdeo //
//////////////////////////////////
// BANNER OBJECT
function Banner(objName)
{
this.obj = objName;
this.aNodes = [];
this.currentBanner =Math.floor(Math.random()*3);
};
// ADD NEW BANNER
Banner.prototype.add = function(bannerType, bannerPath, bannerDuration, height, width, hyperlink) {
this.aNodes[this.aNodes.length] = new Node(this.obj +"_"+ this.aNodes.length, bannerType, bannerPath, bannerDuration, height, width, hyperlink);
};
// Node object
function Node(name, bannerType, bannerPath, bannerDuration, height, width, hyperlink) {
this.name = name;
this.bannerType = bannerType;
this.bannerPath = bannerPath;
this.bannerDuration = bannerDuration;
this.height = height
this.width = width;
this.hyperlink= hyperlink;
// alert (name +"|" + bannerType +"|" + bannerPath +"|" + bannerDuration +"|" + height +"|" + width + "|" + hyperlink);
};
// Outputs the banner to the page
Banner.prototype.toString = function() {
var str = ""
//alert(this.aNodes.length);
for (var iCtr=0; iCtr < this.aNodes.length; iCtr++) //old: iCtr=0
{
//alert(pos);
str = str + '<span name="'+this.aNodes[iCtr].name+'" '
str = str + 'id="'+this.aNodes[iCtr].name+'" ';
str = str + 'class="m_banner_hide" ';
str = str + 'bgcolor="#FFFCDA" '; // CHANGE BANNER COLOR HERE
str = str + 'align="center" ';
str = str + 'valign="top" >\n';
if (this.aNodes[iCtr].hyperlink != ""){
str = str + '<a href="'+this.aNodes[iCtr].hyperlink+'" target="_blank">';
}
if ( this.aNodes[iCtr].bannerType == "FLASH" ){
str=str+ '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" '
str=str+ 'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" '
str=str+ 'width="'+this.aNodes[iCtr].width+'" '
str=str+ 'height="'+this.aNodes[iCtr].height+'" '
str=str+ 'id="bnr_'+this.aNodes[iCtr].name+'" align="middle" VIEWASTEXT> '
str=str+ '<param name="allowScriptAccess" value="always" />'
str=str+ '<param name="movie" value="'+this.aNodes[iCtr].bannerPath+'" />'
str=str+ 'param name="FlashVars" value="'+vars+'" />'
str=str+ '<param name="wmode" value="transparent" />'
str=str+ '<param name="menu" value="false" />'
str=str+ '<param name="quality" value="high" />'
str=str+ '<embed src="'+this.aNodes[iCtr].bannerPath+'" wmode="transparent" menu="false" quality="high" width="'+this.aNodes[iCtr].width+'" height="'+this.aNodes[iCtr].height+'" name="bnr_'+this.aNodes[iCtr].name+'" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
str=str+ '</embed></object>'
}
else if ( this.aNodes[iCtr].bannerType == "IMAGE" ){
str = str + '<img src="'+this.aNodes[iCtr].bannerPath+'" ';
str = str + 'border="0" ';
str = str + 'height="'+this.aNodes[iCtr].height+'" ';
str = str + 'width="'+this.aNodes[iCtr].width+'">';
}
if (this.aNodes[iCtr].hyperlink != ""){
str = str + '</a>';
}
str += '</span>';
}
document.write(str);
str="";
return str;
};
// START THE BANNER ROTATION
Banner.prototype.start = function(){
this.changeBanner();
var thisBannerObj = this.obj;
// CURRENT BANNER IS ALREADY INCREMENTED IN changeBanner() FUNCTION
setTimeout(thisBannerObj+".start()", this.aNodes[this.currentBanner].bannerDuration * 1000);
}
// CHANGE BANNER
Banner.prototype.changeBanner = function(){
var thisBanner;
var prevBanner = -1;
if (this.currentBanner>this.aNodes.length-1)
{
this.currentBanner=0;
}
if (this.currentBanner < this.aNodes.length ){
thisBanner = this.currentBanner;
if (this.aNodes.length > 1){
if ( thisBanner > 0 ){
prevBanner = thisBanner - 1;
}else{
prevBanner = this.aNodes.length-1;
}
}
if (this.currentBanner < this.aNodes.length - 1){
this.currentBanner = this.currentBanner + 1;
}else{
this.currentBanner = 0;
}
}
if (prevBanner >= 0){
document.getElementById(this.aNodes[prevBanner].name).className = "m_banner_hide";
}
document.getElementById(this.aNodes[thisBanner].name).className = "m_banner_show";
}
01-22-07, 12:01 PM
Newbie Coder
Join Date: Jan 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
I am getting a undefined msg on html page with errors on line 60 'vars' in undefined and line 121 'document.getElementByld(...)' is null or not an object.
What I am doing wrong ?
01-22-07, 12:36 PM
Community VIP
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
That means the script isn't finding one of the objects it's looking for. I can't be sure of the exact reason unless you post either your code or a link to the page.
I've modified the mBanner script before and added/changed stuff for people. You should be able to find it in this forum.
01-23-07, 02:40 AM
Newbie Coder
Join Date: Jan 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by arturex
I am getting a undefined msg on html page with errors on line 60 'vars' in undefined and line 121 'document.getElementByld(...)' is null or not an object.
What I am doing wrong ?
just comment or erase this line:
str=str+ 'param name="FlashVars" value="'+vars+'" />'
Last edited by raven80; 01-23-07 at 02:45 AM .
01-23-07, 04:19 AM
Newbie Coder
Join Date: Jan 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
mbanner working
Thanks man ! is working now.´
By the way did you notice the only three first banners declared on html page are showed randomly as the initial ones after each refresh or page reload ?
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
mBanner
Blues
JavaScript
13
06-02-09 09:59 AM