Post by nodric » Fri Apr 27, 2012 10:37 pm

I've use this code to force a click on a banner into a new window.

Code: Select all

javascript:void(window.open('http://www.domain.com','Click for your description'));
This works fine for FF and Chrome, but IE 8 just opens a blank page.

Is there a better way?

Thanks,

N

The Best 4x4xfar


Active Member

Posts

Joined
Wed Jul 06, 2011 10:39 pm

Post by Avvici » Fri Apr 27, 2012 11:58 pm

catalog/view/javascript/common.js
Open up your common.js file and add this code to the very bottom, below everything else:

Code: Select all

function launchGenericPopUp(winName, url, w, h, incScroll) {
	 var centerWidth = (window.screen.width - w) / 2;
    var centerHeight = 0;
	var newWindow = window.open(url, winName, 'width='+w+',height='+h+',menubar=no,location=no,resizable=1,status=no,scrollbars='+incScroll+ ',left=' + centerWidth + ',top=' + centerHeight);
	
	
	if (window.focus) {
		newWindow.focus();
	}
}
function launchNamePopUp(name, url, w, h) {
	launchGenericPopUp(name, url, w, h, 1);
}

function launchNamePopUpNoScroll(name, url, w, h) {
	launchGenericPopUp(name, url, w, h, 0);
}

// launchPopUp: Has to be kept as it is used directly
// in the JSPs. Use launchNamePopUp from now on.


function launchPopUp(url, w, h) {
	launchNamePopUp('NAP_pop', url, w, h);
}

// launchPopUpNoScrolls: As with launchPopUp above
function launchPopUpNoScrolls(url, w, h) {
	launchNamePopUpNoScroll('NAP_pop_noscr', url, w, h);
}
Now, you can call the pop up in your html like this:

Code: Select all

<a href="javascript:launchPopUp('mywebpage.html',900,600);">Click Here</a>
This works in all browsers.

User avatar
Expert Member

Posts

Joined
Tue Apr 05, 2011 12:09 pm
Location - Asheville, NC

Post by nodric » Wed May 02, 2012 12:04 am

Well I tired this, and it doesn't work as expected. I am using 1.5.1.1 if that makes a difference?

All that happens for me is the page that the banner is on simply reloads and appends the url with the
<a href="javascript:launchPopUp('http://www.waltersengines.com',900,600);">Walters Engines</a>
popup url

Maybe I doing something dumb :)

The Best 4x4xfar


Active Member

Posts

Joined
Wed Jul 06, 2011 10:39 pm

Post by pprmkr » Wed May 02, 2012 1:01 am

When you add a script to load the link in a new window, all the banners open in a new wndow. Even the banners to your own information pages.

I posted a possible solution for this 'problem'. See this topic ...

The changes made to sildeshow can alse be made to banner ( controller and template )

User avatar
Active Member

Posts

Joined
Sat Jan 08, 2011 11:05 pm
Location - Netherlands

Post by nodric » Wed May 02, 2012 1:15 am

pprmkr wrote:When you add a script to load the link in a new window, all the banners open in a new wndow. Even the banners to your own information pages.

I posted a possible solution for this 'problem'. See this topic ...

The changes made to slideshow can als0 be made to banner ( controller and template )
Whoa... It's not worth that much hacking...

Another feature that needs adding in to OC.

The Best 4x4xfar


Active Member

Posts

Joined
Wed Jul 06, 2011 10:39 pm
Who is online

Users browsing this forum: No registered users and 283 guests