Current location: Hot Scripts Forums » General Web Coding » JavaScript » pop up window


pop up window

Reply
  #1 (permalink)  
Old 08-26-06, 08:57 AM
Arise Arise is offline
Newbie Coder
 
Join Date: Dec 2005
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
pop up window

hi i have a small problem
i am using ESPBanner

this is the code
Code:
<script type="text/javascript" src="http://www.marsaxlokkfc.com/ESPBanner/espebanner.js"></script><script language="javascript">
                    banner1 = new Banner('banner1');
                    banner1.add("IMAGE", "http://www.marsaxlokkfc.com/Sponsors/images/LaCapagna.jpg", 5, 115, 148,"http://www.marsaxlokkfc.com/Sponsors/index.php?desktop=/Sponsors/images/LaCapagna.jpg");
                    banner1.add("IMAGE", "http://www.marsaxlokkfc.com/Sponsors/images/duncan.gif", 5, 115, 148,"javascript:window.open(\"http://marsaxlokkfc.com/highlights/highlits.php\",\"_blank\",\"width=800,height=550,status=no,toolbar=no,scrollbars=no\")");
                    banner1.add("FLASH", "http://www.marsaxlokkfc.com/ESPBanner/espebanner/fun.swf", 5, 115, 148,"espebanner.html");
                    banner1.add("IMAGE", "http://www.marsaxlokkfc.com/Sponsors/images/dinosigns.jpg", 5, 115, 148,"");
                    banner1.add("IMAGE", "http://www.marsaxlokkfc.com/Sponsors/images/spagnol.gif", 5, 115, 148,"");
                  
                    document.write(banner1);
                    banner1.start();
        </script>
and thi is the .js code
Code:
// BANNER OBJECT
function Banner(objName){
	this.obj = objName;
	this.aNodes = [];
	this.currentBanner = 0;
	
};

// 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 = ""
	for (var iCtr=0; iCtr < this.aNodes.length; iCtr++){
		str = str + '<span name="'+this.aNodes[iCtr].name+'" '
		str = str + 'id="'+this.aNodes[iCtr].name+'" ';
		str = str + 'class="m_banner_hide" ';
		str = str + 'bgcolor="#000066" ';	// 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+'">';
		}
			
		if ( this.aNodes[iCtr].bannerType == "FLASH" ){
			str = str + '<OBJECT '
			str = str + 'classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '
			str = str + 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,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+'" '
			str = str + 'ALIGN="" '
			str = str + 'VIEWASTEXT>'
			str = str + '<PARAM NAME=movie VALUE="'+ this.aNodes[iCtr].bannerPath + '">'
			str = str + '<PARAM NAME=quality VALUE=high>'
			str = str + '<PARAM NAME=bgcolor VALUE=#FFFCDA>'
			str = str + '<EMBED ';
			str = str + 'src="'+this.aNodes[iCtr].bannerPath+'" '
			str = str + 'quality=high '
//			str = str + 'bgcolor=#FFFCDA '
			str = str + 'WIDTH="'+this.aNodes[iCtr].width+'" '
			str = str + 'HEIGHT="'+this.aNodes[iCtr].height+'" '
			str = str + 'NAME="bnr_'+this.aNodes[iCtr].name+'" '
			str = str + 'ALIGN="center" '
			str = str + 'TYPE="application/x-shockwave-flash" '
			str = str + 'PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">'
			str = str + '</EMBED>'
			str = str + '</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 cahngeBanner() 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 ){
		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";
}
now if you see the top code i am tring to make a pop up link but for some reson it gives me an error this is the link i put for the pop up
Code:
banner1.add("IMAGE", "http://www.marsaxlokkfc.com/Sponsors/images/duncan.gif", 5, 115, 148,"javascript:window.open(\"http://marsaxlokkfc.com/highlights/highlits.php\",\"_blank\",\"width=800,height=550,status=no,toolbar=no,scrollbars=no\")");
but it dose not work any help on this one pls

thanks to all
Reply With Quote
  #2 (permalink)  
Old 08-26-06, 04:27 PM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
What kind of error?

Without testing the code, I think the quotes cause the problem.
This is what the generated link tag for the last line you posted will look like.
Code:
<a href="javascript:window.open("http://marsaxlokkfc.com/highlights/highlits.php", "_blank", "width=800, height=550,status=no,toolbar=no,scrollbars=no")"></a>
Note the red double quotes, they are inserted by the script when inserting the hyperlink in the tag string. The browser will think that the first quote you inserted, after open(, is the end of that string. That makes the rest of the link look like one huge syntax error.

The solution would be to use single quotes inside the hyperlink string.
You would not need to escape them with \ since they'd be recognized as a substring or quote by the browser.
Code:
banner1.add("IMAGE", "http://www.marsaxlokkfc.com/Sponsors/images/duncan.gif", 5, 115, 148,"javascript:window.open('http://marsaxlokkfc.com/highlights/highlits.php', '_blank', 'width=800,height=550,status=no,toolbar=no, scrollbars=no')");
That will make the tag look like this.
Code:
<a href="javascript:window.open('http://marsaxlokkfc.com/highlights/highlits.php', '_blank', 'width=800, height=550,status=no,toolbar=no, scrollbars=no')"></a>
Which makes sense to the browser.
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.

Last edited by TwoD; 08-26-06 at 04:31 PM. Reason: what? no bold quotes?
Reply With Quote
  #3 (permalink)  
Old 08-27-06, 10:12 AM
Arise Arise is offline
Newbie Coder
 
Join Date: Dec 2005
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
hi thanks for your help

but when i made this
Code:
banner1.add("IMAGE", "http://www.marsaxlokkfc.com/Sponsors/images/duncan.gif", 5, 115, 148,"<a href="javascript:window.open('http://marsaxlokkfc.com/highlights/highlits.php', '_blank', 'width=800, height=550,status=no,toolbar=no, scrollbars=no')"></a>");
it gives this error now: Expected ')'
can you tell me why

thank alot
Reply With Quote
  #4 (permalink)  
Old 08-27-06, 04:24 PM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
I meant for you to use this code (second from bottom in my last post)
Code:
banner1.add("IMAGE", "http://www.marsaxlokkfc.com/Sponsors/images/duncan.gif", 5, 115, 148,"javascript:window.open('http://marsaxlokkfc.com/highlights/highlits.php', '_blank', 'width=800,height=550,status=no,toolbar=no, scrollbars=no')");
The last code box in my previous post shows the finished link tag generated by the script when it gets those parameters.
You don't need to include the <a href="...."></a> part when setting the hyperlink attribute in banner1.add. That part will automatically be inserted when the links for the banners are generated and placed on the page.
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Reply With Quote
  #5 (permalink)  
Old 10-19-09, 09:18 AM
sandy76 sandy76 is offline
New Member
 
Join Date: Oct 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Manually navigating the banners

hi

I am using espebanner to get the rotating banners on my home page. IT works absolutely perfect. Is it possible to do a manual rotation with the same script. For example, if i put next and previous buttons below the banner ,. I want the option to be given to people where they can see the banner rotating or if they can click next and previous if they cant wait . The example would be North Jersey Local News, Sports, Classifieds, Jobs, Better Living - NorthJersey.com. This is the website which has this feature

Any help on this would be appreciated
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pop Up Window mortgage-pro-seo JavaScript 1 04-11-05 03:42 AM
[Help] Javascript pop up window with background color empty.container JavaScript 1 01-13-05 03:11 AM
Blank window pop up message leocordero Script Requests 1 12-12-04 01:43 PM
how to make a pop up window? honggesing JavaScript 1 10-10-04 09:22 PM
pop up window nitefire JavaScript 1 08-03-04 10:10 AM


All times are GMT -5. The time now is 11:15 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.