Recent Topics

1 Sep 17, 2009 11:57    

My b2evolution Version: 2.x

Hi,

I am trying to setup a pop up window using the pop_up_window javascript function located in the functions.js file.

I am able to create the popup but am having trouble with the "target" attribute. Basically, I don't know what to put in there when calling the function from my html widget!

Currently, I get my popup but the source page goes blank returning the text "false".

Any ideas would be gratefully welcomed!

This is the function:


/**
 * Opens a window, centers it and makes sure it gets focus.
 */
function pop_up_window( href, target, width, height, params )
{
 	if( typeof(width) == 'undefined' )
 	{
		width = 750;
	}

 	if( typeof(height) == 'undefined' )
 	{
		height = 550;
	}

	var left = (screen.width - width) / 2;
	var top = (screen.height - height) / 2;

 	if( typeof(params) == 'undefined' )
	{
		params = 'scrollbars=yes, status=yes, resizable=yes, menubar=yes';
	}

	params = 'width=' + width + ', height=' + height + ', ' + 'left=' + left + ', top=' + top + ', ' + params;

	// Open window:
	opened = window.open( href, target, params );

	// Bring to front!
	opened.focus();

	if( typeof(openedWindows) == 'undefined' )
	{
		openedWindows = new Array(opened);
	}
	else
	{
		openedWindows.push(opened);
	}

	// Tell the caller there is no need to process href="" :
	return false;
}

This is the html I am currently using:


Click <a href="javascript:pop_up_window( 'http://XXXXXX/XXX/?p=subscribe&id=3', '400', '600', '','scrollbars=no, status=no, resizable=no, menubar=no')">here</a> to recieve regular updates.

2 Sep 17, 2009 13:25

function pop_up_window( href, target, width, height, params )

add '' before , '400'

¥

3 Sep 17, 2009 14:31

Thanks, I did that but I still get the error page along with the pop up window.

The code now reads:

Click <a href="javascript:pop_up_window( 'http://XXXXX/XXXX/?p=subscribe', '', '400', '600', 'scrollbars=no, status=no, resizable=no, menubar=no')">here</a> to recieve regular updates.

4 Sep 17, 2009 14:49

Click <a href='http://gurcharansingh.co.uk/gsolist/?p=subscribe' onclick="return javascript:pop_up_window( this.href, '', '400', '600', 'scrollbars=no, status=no, resizable=no, menubar=no')">here</a> to recieve regular updates.

¥

5 Sep 17, 2009 14:58

Thanks but that just gives me the subscribe page in the main window without any popup...

6 Sep 17, 2009 15:38

I basically have 2 requirements here:

When the link is clicked:

1) The source page remains completely unchanged (this includes not needing to be refreshed)
2) The pop up window appears (with predefined settings e.g. width, height, etc.)

I hope this helps to clarify.

7 Sep 17, 2009 16:35

Sorry, remove the "javascript:" from onclick=" return javascript;"

¥

8 Sep 17, 2009 17:20

That's done it!!!

Thank you so much - reps coming your way!

R


Form is loading...