views:

207

answers:

3

Hi,

I'm new to Jquery, so please bear with me. I'm trying to create a function that will programmatically open popup windows. I'm running the following code in Firefox, and it seems to work except that the popup windows disregards the toolbar/menubar/scrollbars/resizable/location parameters (they are still visible/functional and I would like to disable all of them):

wparams[0] = {windowURL:"site.html",height:100,width:100,left:500,top:500,toolbar:0,menubar:01,scrollbars:0,resizable:0,location:0}

var launchWindow = function(p)
{
    $('.popup').popupWindow(wparams[p]).trigger("click"); 
}

var begin = function()
{
        launchWindow(0);
}

I would like the popups I'm using jQuery-swip popup plugin (http://swip.codylindley.com/popupWindowDemo.html), am wondering what's wrong with the above code.

Also, when I try to run this code in chrome/safari (typing begin(); in the console) it returns undefined, whereas in Firefox it runs. I'm also confused as to why this is happening.

Thanks.

A: 

Does this work?

wparams[0] = {windowURL:"site.html","height:100,width:100,left:500,top:500,toolbar:0,menubar:01,scrollbars:0,resizable:0,location:0"}
hallie
A: 

That's a weird way to define the "wparams" array - what happens if you do this:

var wparams = [
   {windowURL:"site.html", height:100, width:100, left:500, top:500, toolbar:0, menubar:01, scrollbars:0, resizable:0, location:0}
];

It's not really clear why you're setting that up as an array; I guess maybe there might be other popup configurations stored in it. If that's the case, you'd just write them inside those square brackets, separated by commas.

Pointy
JavaScript should support jagged arrays http://www.devx.com/tips/Tip/12455
Omar Abid
A: 

I didn't understand 'when' you want to open the popup, if when the page complete loading, so it should be

$(document).ready(function() {
launchWindow(0);
});

Also can you explain to me why use trigger(click)??? As of the plugin documentation, this should work like that

var launchWindow = function(p)
{
    $('.popup').popupWindow(wparams[p]); 
}
Omar Abid